Skip to content
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

Parameterized vararg called with no arguments #28278

Closed
HarrisonGrodin opened this issue Jul 25, 2018 · 2 comments
Closed

Parameterized vararg called with no arguments #28278

HarrisonGrodin opened this issue Jul 25, 2018 · 2 comments
Labels
error handling Handling of exceptions by Julia or the user

Comments

@HarrisonGrodin
Copy link
Contributor

HarrisonGrodin commented Jul 25, 2018

During the development of v0.7, the following behavior has been introduced. When a parameterized vararg is called with no arguments, the use of the parameter (in the following case, T) will produce an UndefVarError. (This is in contrast to the v0.6 behavior of producing a MethodError.)

julia> f(xs::Val{T}...) where {T} = T
f (generic function with 1 method)

julia> f()
ERROR: UndefVarError: T not defined
Stacktrace:
 [1] f() at ./REPL[5]:1
 [2] top-level scope at none:0

Assuming this is the correct behavior, a more descriptive error message (including where the variable was supposed to be derived/"defined") would likely be less confusing.


Edit: @rdeits pointed me to #23117 and this Discourse conversation, where the change and its implications are described.

@JeffBezanson JeffBezanson added the error handling Handling of exceptions by Julia or the user label Jul 25, 2018
@JeffBezanson
Copy link
Member

Yes, this is the new intended behavior. The action item is probably to improve the error message.

@vtjnash
Copy link
Member

vtjnash commented Feb 1, 2024

done

julia> f()
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.

@vtjnash vtjnash closed this as completed Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error handling Handling of exceptions by Julia or the user
Projects
None yet
Development

No branches or pull requests

3 participants