File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ function _main(argc::Cint, argv::Ptr{Ptr{Cchar}})::Cint
3737 return Main. main (args)
3838end
3939
40- let mod = Base. include (Main, ARGS [1 ])
40+ let include_result = Base. include (Main, ARGS [1 ])
4141 Core. @latestworld
4242 if ARGS [2 ] == " --output-exe"
4343 have_cmain = false
@@ -49,6 +49,11 @@ let mod = Base.include(Main, ARGS[1])
4949 break
5050 end
5151 end
52+ elseif include_result isa Module && isdefined (include_result, :main )
53+ error ("""
54+ The `main` function must be defined in `Main`. If you are defining it inside a
55+ module, try adding `import .$(nameof (include_result)) .main` to $(ARGS [1 ]) .
56+ """ )
5257 end
5358 if ! have_cmain
5459 if Base. should_use_main_entrypoint ()
@@ -59,7 +64,7 @@ let mod = Base.include(Main, ARGS[1])
5964 error (" `@main` must accept a `Vector{String}` argument." )
6065 end
6166 else
62- error (" To generate an executable a `@main` function must be defined." )
67+ error (" To generate an executable a `@main` function must be defined in the `Main` module ." )
6368 end
6469 end
6570 end
You can’t perform that action at this time.
0 commit comments