idris-lang / Idris2

A purely functional programming language with first class types
https://idris-lang.org/
Other
2.53k stars 378 forks source link

Unable to `--exec` ambiguous mains #3398

Open buzden opened 1 month ago

buzden commented 1 month ago

Steps to Reproduce

Consider I have a file Main.idr with the following contents:

namespace XX

  export
  main : IO ()
  main = putStrLn "Hi, XX!"

namespace YY

  export
  main : IO ()
  main = putStrLn "Hi, YY!"

If we run

$ idris2 --exec main Main.idr

we expectedly get

Error: Ambiguous elaboration. Possible results:
    Main.XX.main
    Main.YY.main

Now, try to specify the namespace by running either

$ idris2 --exec YY.main Main.idr

or

$ idris2 --exec Main.YY.main Main.idr

Expected Behavior

Runs successfully and prints

Hi, YY!

or at least saying that namespaced main functions are not supported, if so.

Observed Behavior

Error: Undefined name YY.main. 

and

Error: Undefined name Main.YY.main.