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

Worldage error with @generated in let block only in assignments #37553

Open
simeonschaub opened this issue Sep 12, 2020 · 1 comment
Open

Worldage error with @generated in let block only in assignments #37553

simeonschaub opened this issue Sep 12, 2020 · 1 comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage)

Comments

@simeonschaub
Copy link
Member

simeonschaub commented Sep 12, 2020

This one is really weird. It happens only if the let block in question is on the rhs of an assignment, otherwise it works just fine:

julia> a = let
       @generated f(x) = 1
       f(1)
       end
ERROR: MethodError: no method matching #s24#27(::Type{var"#f#28"}, ::Type{Int64})
The applicable method may be too new: running in world age 28483, while current world is 28484.
Closest candidates are:
  #s24#27(::Any, ::Any) at none:0 (method too new to be called from this world context.)
Stacktrace:
 [1] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any, N} where N)
   @ Core ./boot.jl:556
 [2] top-level scope
   @ REPL[14]:3

julia> let
       @generated f(x) = 1
       f(1)
       end
1

It's also interesting what happens if I use if @generated for f:

julia> a = let
       f(x) = if @generated() 1 else error() end
       f(1)
       end
ERROR: 
Stacktrace:
 [1] error()
   @ Base ./error.jl:42
 [2] (::var"#f#24")(x::Int64)
   @ Main ./REPL[12]:2
 [3] top-level scope
   @ REPL[12]:3

julia> let
       f(x) = if @generated() 1 else error() end
       f(1)
       end
1

That it's a worldage error is what probably confuses me the most. I would have thought this could be an issue during lowering, but perhaps it occurs later on?
cc: @mcabbott

@simeonschaub
Copy link
Member Author

Screenshot from 2022-01-13 22-00-25

@JeffBezanson Any ideas why the produced lowered code would be so different here? (left one is just with a = in front, right one without) It seems to happen somewhere after form expansion at least.

@vtjnash vtjnash added the compiler:lowering Syntax lowering (compiler front end, 2nd stage) label Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage)
Projects
None yet
Development

No branches or pull requests

2 participants