-
-
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
Defining a Foo{T}
constructor for Foo{T, S <: T}
#39280
Comments
Foo{T}
constructor for struct Foo{T, S <: T} end
Foo{T}
constructor for Foo{T, S <: T}
It helps here to understand that two different processes are happening: (1) picking a method to call, and (2) once inside the method, determining the value of
(The type the method is defined on just gets wrapped in
so we think we don't know the value of |
Record the 'scope' of the variable that was undefined (the Module, or a descriptive word such as :local or :static_parameter). Add that scope to the error message, and expand the hint suggestions added by the REPL to include more specific advice on common mistakes: - forgetting to set an initial value - forgetting to import a global - creating a local of the same name as a global - not matching a static parameter in a signature subtype Fixes #17062 (although more could probably be done to search for typos using REPL.string_distance and getting the method from stacktrace) Fixes #18877 Fixes #25263 Fixes #35126 Fixes #39280 Fixes #41728 Fixes #48731 Fixes #49917 Fixes #50369
Record the 'scope' of the variable that was undefined (the Module, or a descriptive word such as :local or :static_parameter). Add that scope to the error message, and expand the hint suggestions added by the REPL to include more specific advice on common mistakes: - forgetting to set an initial value - forgetting to import a global - creating a local of the same name as a global - not matching a static parameter in a signature subtype Fixes #17062 (although more could probably be done to search for typos using REPL.string_distance and getting the method from stacktrace) Fixes #18877 Fixes #25263 Fixes #35126 Fixes #39280 Fixes #41728 Fixes #48731 Fixes #49917 Fixes #50369
The manual doesn't provide a definition for what it means to define a constructor for a parametric type where the number of type parameters accepted by the constructor is fewer than the number of type parameters for the type. In simple cases, it works as expected, but for more complicated cases, the lack of a formal semantics leads to mass confusion, as demonstrated by this Discourse thread.
From that thread, we came up with the following MWE.
This works:
But this does not:
Without a definition of what it means to define
Foo{T}() where {T} = # ...
it's difficult to know if this is a bug or if this is expected behavior. And if it is the expected behavior, it would be nice to know what the semantic rule is that explains this behavior (and it would be nice to have that explanation in the manual).The text was updated successfully, but these errors were encountered: