-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Foo{T >: Int} gives ERROR: UndefVarError: T
not defined
#54893
Comments
Missed the bit about julia> struct Foo{T >: Int}
x::T
end
julia> Foo(1.0)
ERROR: UndefVarError: `T` not defined in static parameter matching
Suggestion: run Test.detect_unbound_args to detect method arguments that do not fully constrain a type parameter.
Stacktrace:
[1] Foo(x::Float64)
@ Main ./REPL[1]:2
[2] top-level scope
@ REPL[2]:1
julia> versioninfo()
Julia Version 1.12.0-DEV.512
Commit d01d2561e6* (2024-05-11 04:45 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: 24 × AMD Ryzen 9 7900X 12-Core Processor
WORD_SIZE: 64
LLVM: libLLVM-17.0.6 (ORCJIT, znver4)
Threads: 23 default, 1 interactive, 23 GC (on 24 virtual cores)
Environment:
JULIA_PKG_USE_CLI_GIT = true |
This should presumably be a |
According to the suggestion there, this is a |
Well there are two separate bugs here:
|
The |
If we are throwing an Assume we are going the ignoring lower bound route, then |
The struct definition must work, anything else would be breaking. |
I'm not sure if there is an actual use case for the following type specification, but at least this shouldn't give an
UndefVarError
when one callsFoo(1.0)
andFoo(1)
works.I get this is putting the type bound as
T
instead ofInt
, but would be nice to have a hint somewhere. I'm not sure how to add it if someone knows.The text was updated successfully, but these errors were encountered: