-
-
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
regression: {.pure.} pragma fails to hide enum #16462
Comments
@geekrelief can you reduce this to an example with just 2 (say mod1, mod2) modules and no imports besides mod1 importing mod2 or vice versa? |
Yes, I'll make this my next priority. Thanks! |
It's actually an issue with the {.pure.} pragma #v.nim
type
V* {.pure.} = enum
A #test.nim
import v
template defA() =
proc onA(a:A) =
echo A.val
type
A* = object
val: int
defA()
V.A should be hidden with the pure pragma per the manual. https://nim-lang.org/docs/manual.html#pragmas-pure-pragma |
There was discussion about this in #8066. For now |
Those issues you referenced are quite old. This was working until pretty recently. I tried both of your suggestions. Adding
|
Ok, my point is that something did change, but you shouldn't change the issue title to "{.pure.} doesn't work", because that's an old issue and not the problem here. The incremental compilation commit broke something with symbols as the mixin error shows. |
I was trying to be more helpful with the title. Would you prefer I change it to something else? |
#15935 also breaks https://github.com/ftsf/nico - ftsf/nico#49 (not sure if this is the same bug): # a.nim
import sdl except Scancode
import other
let a = SCANCODE_LEFT # other.nim
type
Scancode* = enum
SCANCODE_LEFT = 80 # sdl.nim
type
Scancode* = enum
SCANCODE_LEFT = 80 The error is:
|
@geekrelief this can also be worked around by declaring the template underneath the type declaration like so: #v.nim
type
V* {.pure.} = enum
A
#test.nim
import v
type
A* = object
val: int
template defA() =
proc onA(a:A) =
echo A.val
defA() |
Fixes pragmagic#81 Alternate workaround for nim-lang/Nim#16462 without changing VariantType.
Fixes #81 Alternate workaround for nim-lang/Nim#16462 without changing VariantType.
@jyapayne Thanks for the suggestion. I saw the commit for godot-nim, and it helps for that case. But this issue popped up again in another place when I implemented signal declarations and got a name clash with |
Ah, I see. You're right that there's another clash down the line. @Araq do you have any advice on where this could be fixed? I'm interested in attempting to fix the issue |
Or @timotheecour :) |
We should do this nim-lang/RFCs#373 (comment) In general, the compiler must produce sym choices that are then collapsed taking into account more context. For example in |
Hello @Yardanico, the pure enum version of your example works in devel # a.nim
import sdl except Scancode
import other
let a = SCANCODE_LEFT # other.nim
type
Scancode* {.pure.} = enum
SCANCODE_LEFT = 80 # sdl.nim
type
Scancode* {.pure.} = enum
SCANCODE_LEFT = 80 see also: #19692 |
Compiling with 979148e breaks compilation of https://github.com/pragmagic/godot-nim
Current Output
C:\godot\gdnim\deps\godot\core\poolarrays.nim(128, 16) template/generic instantiation of
definePoolArray
from hereC:\godot\gdnim\deps\godot\core\poolarrays.nim(49, 26) Error: type expected, but got symbol 'Array' of kind 'enumField'
Expected Output
This compiled without error before.
Additional Information
979148e breaks.
Two modules are involved. https://github.com/pragmagic/godot-nim/blob/master/godot/core/poolarrays.nim and https://github.com/pragmagic/godot-nim/blob/master/godot/core/arrays.nim
poolarrays has a template that fails because Array is not found.
poolarrays imports arrays online 125.
The text was updated successfully, but these errors were encountered: