Skip to content

Including code that defines a module within a function definition does not fail!? #39421

@PetrKryslUCSD

Description

@PetrKryslUCSD

I thought this was illegal. Yet with Julia 1.5.3 including the file M.jl runs:

# M.jl

# This works
function main()
    include("A.jl")
end; 
main()

# When the contents of the file A.jl is pasted directly into the function, there is an error.
#function main()
#    module App
#    function main()
#        println("in App")
#    end; main()
#    end
#end; 
#main()

and

# A.jl
module App
function main()
    println("in App")
end; main()
end

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