-
-
Notifications
You must be signed in to change notification settings - Fork 5.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
Inner constructor type constraint fails with UndefVarError in iteration #38888
Labels
bug
Indicates an unexpected problem or unintended behavior
Comments
JeffBezanson
added
the
bug
Indicates an unexpected problem or unintended behavior
label
Dec 15, 2020
JeffBezanson
added a commit
that referenced
this issue
Dec 15, 2020
JeffBezanson
added a commit
that referenced
this issue
Dec 15, 2020
JeffBezanson
added a commit
that referenced
this issue
Dec 16, 2020
KristofferC
pushed a commit
that referenced
this issue
Dec 19, 2020
staticfloat
pushed a commit
that referenced
this issue
Jan 15, 2021
ElOceanografo
pushed a commit
to ElOceanografo/julia
that referenced
this issue
May 4, 2021
staticfloat
pushed a commit
that referenced
this issue
Dec 23, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consider the following bit of code:
This will fail with an
UndefVarError: S not defined
. Once this error is thrown, it is not possible to constructMyStruct
anymore. However, when restarting Julia constructing an instance ofMyStruct
in global scope works. If you then execute the list comprehension it also works.Note that the same happens if you use a function instead of the list comprehension, inside of which
MyStruct(n)
is called, so I guess it's related to scoping.A simple workaround is to relax the type constraint, e.g.
S<:Integer
works as expected. Still, it's strange that the list comprehension works whenMyStruct
is constructed in global scope before.Version info:
The text was updated successfully, but these errors were encountered: