-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #798 (relying on undefined behaviour) #802
Conversation
src/nimblepkg/packageparser.nim
Outdated
@@ -464,6 +464,7 @@ proc getInstalledPkgs*(libsDir: string, options: Options): | |||
pkg = readPackageInfo(nimbleFile, options, onlyMinimalInfo=false) | |||
except ValidationError: | |||
let exc = (ref ValidationError)(getCurrentException()) | |||
pkg = exc.pkgInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way - this procedure (getInstalledPkgs
) is not used anywhere, is that okay?
src/nimblepkg/packageparser.nim
Outdated
hint: string = "", warnAll = false) = | ||
raise newValidationError(msg, warnInstalled, hint, warnAll) | ||
hint = "", warnAll = false) = | ||
raise PackageInfo().newValidationError(msg, warnInstalled, hint, warnAll) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might not look correct - but in fact it is - it's only used this way in validatePackageName
which is only called from readPackageInfo
where it's not covered in a try/except block so it won't make sense (and will require changing more code) to pass PackageInfo() there.
I also could've made a new newValidationError proc without info: PackageInfo, but I wanted to keep my changes as minimal as possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! I've got an idea that may make this change easier, are you happy to implement it?
basically just change readPackageInfo
to take a var PackageInfo
instead of returning it.
But really, it's quite strange that we are using pkg
once it's failed validation, the real fix is probably to stop doing that.
This PR fixes #798.
I'm not sure if this is the best way, but it requires the least amount of changes to the code. It's required for nim-lang/Nim#14390 .
I'm not 100% sure that I fixed all places where that behaviour was used, so please comment if you find any issues.