Skip to content

"Invalid declaration" inside a constant definition when loading a module #59128

@frankwswang

Description

@frankwswang

MWE (reproduced on 1.12.0-rc1 and 1.13.0-DEV.917):

First, define a module script "MyMod.jl" in the root directory:

module MyMod

const SubShellDict::Base.ImmutableDict{String, Int} = let
    key = ["S", "P", "D"]
    val = collect(0 : 2)
    mapreduce(Base.ImmutableDict, key, val, 
              init=Base.ImmutableDict{String, Int}()) do key, val
        key=>val
    end
end

end

Then try loading the script in a freshly started Julia REPL:

julia> include("./MyMod.jl")
ERROR: LoadError: method: invalid declaration
Stacktrace:
 [1] top-level scope
   @ .\MyMod.jl:6
 [2] include(mapexpr::Function, mod::Module, _path::String)
   @ Base .\Base.jl:312
 [3] top-level scope
   @ REPL[1]:1

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviorcompiler:loweringSyntax lowering (compiler front end, 2nd stage)regression 1.12Regression in the 1.12 release

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions