Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to --exec ambiguous mains #3398

Closed
buzden opened this issue Oct 10, 2024 · 1 comment · Fixed by #3438
Closed

Unable to --exec ambiguous mains #3398

buzden opened this issue Oct 10, 2024 · 1 comment · Fixed by #3438

Comments

@buzden
Copy link
Contributor

buzden commented Oct 10, 2024

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. 
@spcfox
Copy link
Contributor

spcfox commented Dec 2, 2024

The reason for this behavior is that --exec does not parse the string, but simply wraps it in Basic

postOptions res (ExecFn str :: rest)
= do ignore $ execExp (PRef EmptyFC (UN $ Basic str))

spcfox added a commit to spcfox/Idris2 that referenced this issue Dec 2, 2024
spcfox added a commit to spcfox/Idris2 that referenced this issue Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants