-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
overloadable enums no longer experimental #20298
Conversation
Please rebase. |
2d91e1f
to
39bd08b
Compare
Rebased, CI failing because gitlab is down |
Thanks for your hard work on this PR! Hint: mm: orc; threads: on; opt: speed; options: -d:release |
This PR caused a regression, there is apparently an issue with overloadable enums: Current repro (using nim devel): git clone git@github.com:status-im/nim-libp2p.git
cd nim-libp2p
nimble install -dy
nim c libp2p/multiaddress.nim (ofc the issue was not directly caused by this PR, this PR just made it more apparent) I'll try to make a proper reproduction & open issue in a few days, if no one took a look in the meantime |
The error message given there is the same as given here: {.experimental: "overloadableEnums".}
type A = enum foo
type B = enum foo
let x = {foo} # ordinal type expected This is supposed to be an error but the message is terrible, it is trying to say "ambiguous type". If the case in that code is the same as this one (I am not familiar with the codebase and I would have to go through every import to know), there is a universal workaround of qualifying, i.e. doing |
Thanks for the pointer! Line which cause the crash:
Indeed, there is already a Does this mean we have to live in fear that one of the symbol we import starts to use the same name as us, and forces us to rename our field, or always specify |
The only saving grace there without overloadableEnums was that MAKind was defined in the same module and not an import. If it was defined in an import, i.e. if two imports had the same name for a enum field, then either it would give the same ambiguity error, or it would pick the one from the last import, which is probably bad behavior. You should never have to rename the field, the obvious solution to me is qualifying it (add By far the biggest issue there IMO, and potentially in other places, is the error message saying basically nothing. Even if it said |
Unfortunately, it doesn't work either with type A = enum foo, bar
type B = enum foo
case bar:
#of foo: echo "ok" # works
of {foo, bar}: echo "ok" # doesn't
else: echo "too bad" So this seems like an issue, where (and indeed, better error message) |
I think this CI fail is also connected to the changes in this PR: The compiler is confusing |
currently includes #20126 as this is required for packages to passwas merged