JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.46k stars 5.46k forks source link

Multiline comment parsing error on 1.11-rc3 #55792

Open j-fu opened 4 days ago

j-fu commented 4 days ago

When loaded via using from a directory on LOAD_PATH, the following code works on Julia 1.10.5, but fails on 1.11-rc3 as well on nightly (02549d5c54e):

#=
Demonstrate a parsing error when 
using multiline comments on Julia 1.11-rc3
^^^^^
   This `using` word makes 1.11-rc3 believe that 
there is a `using` statement before the module
declaration when the code is loaded from a directory
on LOAD_PATH
=#
module UsingError
main()=println("Hi there!")
end

This is the error message:

julia> using UsingError
[ Info: Precompiling UsingError [top-level]
ERROR: LoadError: Package UsingError [top-level] source file /home/fuhrmann/Wias/work/julia/dev/VoronoiFVM/examples/UsingError.jl has a using/import before a module declaration.
Stacktrace:
[1] check_src_module_wrap(pkg::Base.PkgId, srcpath::String)
@ Base ./loading.jl:2718
[2] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
@ Base ./loading.jl:2733
[3] top-level scope
@ stdin:4
in expression starting at stdin:4
ERROR: Failed to precompile UsingError [top-level] to "/home/fuhrmann/.julia/compiled/v1.11/jl_RH516U".
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, keep_loaded_modules::Bool; flags::Cmd, cacheflags::Base.CacheFlags, reasons::Dict{…})
@ Base ./loading.jl:3036
[3] (::Base.var"#1080#1081"{Base.PkgId})()
...
KristofferC commented 4 days ago

https://github.com/JuliaLang/julia/pull/51635

"How do you parse Julia with regexes?"