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

@nospecialize could use argument validation #49512

Open
jakobnissen opened this issue Apr 26, 2023 · 0 comments
Open

@nospecialize could use argument validation #49512

jakobnissen opened this issue Apr 26, 2023 · 0 comments
Labels
domain:error messages Better, more actionable error messages

Comments

@jakobnissen
Copy link
Contributor

jakobnissen commented Apr 26, 2023

I recently discovered a few footguns with @nospecialize:

julia> @nospecialize f(x) = x + 1

julia> f
ERROR: UndefVarError: `f` not defined

This happens because the function definition gets parsed as a kwarg to @nospecialize. This makes no sense of course, but no error is thrown.

Similarly

julia> function f(a, b)
           @nospecialize a, c
           a + b
       end
f (generic function with 1 method)

julia> f(1, 2)
3

Here, the compiler doesn't complain that c is not even an argument. This looks like a mistake that someone will 100% make eventually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:error messages Better, more actionable error messages
Projects
None yet
Development

No branches or pull requests

2 participants