Skip to content

Adding methods to eval or include throws in v1.12 #57070

@nickrobinson251

Description

@nickrobinson251

...if the function name isn't fully qualified or explicity imported

e.g.

> julia +nightly -q --startup-file=no
julia> VERSION
v"1.12.0-DEV.1898"

julia> eval(::Int) = 42
ERROR: cannot define function eval; it already has a value
Stacktrace:
 [1] top-level scope
   @ none:0
 [2] top-level scope
   @ REPL[2]:1

julia> include(::Int) = 0
ERROR: cannot define function include; it already has a value
Stacktrace:
 [1] top-level scope
   @ none:0
 [2] top-level scope
   @ REPL[3]:1

julia> Base.eval(::Int) = 42  # works

julia> Base.include(::Int) = 0  # works

Note the error message is different from trying to extend other methods without qualification e.g.

julia> VERSION
v"1.12.0-DEV.1898"

julia> 1+2  # so Base.+ has been used
3

julia> +(::String) = 42
ERROR: invalid method definition in Main: function Base.+ must be explicitly imported to be extended
Stacktrace:
 [1] top-level scope
   @ none:0
 [2] top-level scope
   @ REPL[3]:1

Whereas in v1.11

nickr@RAI-Mac ~/r/r/p/Tropea> julia +1.11 -q --startup-file=no
julia> VERSION
v"1.11.2"

julia> eval(::Int) = 42
eval (generic function with 2 methods)

julia> include(::Int) = 0
include (generic function with 3 methods)

Was this a deliberate change?

It broke some of our code that happened to use the name eval (not meaning to extend Base.eval), so wanted to check the new behaviour was intended

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions