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

Add error for overloaded Haskell constructors #328

Merged
merged 4 commits into from
Jul 10, 2024

Conversation

PPKFS
Copy link
Contributor

@PPKFS PPKFS commented Jun 8, 2024

Solves #125.

Unfortunately, it seems the Agda compiler only does its compiler magic for each definition independently, so there is no state carried over as to the previous definitions that have been compiled.

We check all the constructors generated for duplicates prior to writeOutput in postCompile and refuse to continue if there are duplicates. This does also add scaffolding for future post-compilation, pre-render verification steps.

@jespercockx
Copy link
Member

Unfortunately, it seems the Agda compiler only does its compiler magic for each definition independently, so there is no state carried over as to the previous definitions that have been compiled.

Yes, we have discussed this limitation before, and then we came to the conclusion that the best way to have some shared state would be to use an IORef (which is possible since the C monad implements MonadIO).

However, for this issue the solution you propose also seems like a reasonable approach.

@jespercockx jespercockx self-requested a review June 9, 2024 09:53
src/Agda2Hs/Compile.hs Outdated Show resolved Hide resolved
test/Fail/Issue125.agda Outdated Show resolved Hide resolved
src/Main.hs Outdated
@@ -71,7 +71,7 @@ backend = Backend'
, preCompile = checkConfig
, postCompile = \ _ _ _ -> return ()
, preModule = moduleSetup
, postModule = writeModule
, postModule = \opts env isM m out -> verifyOutput opts env isM m out >> writeModule opts env isM m out
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could just make verifyOutput a part of writeModule, or else add a new function that does these two functions in sequence?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a new function is probably best. Having writeModule, in Render, also do final verification feels like a weird mixup of concerns

@jespercockx
Copy link
Member

The test suite fails on the following:

== Comparing output ==
diff -r build/Issue125.err golden/Issue125.err
1c1
< Cannot generate multiple constructors with the same identifier: ACtr
---
> Found multiple declarations of constructor: ACtr

Please run make test and make golden and then commit the changes to the golden files.

@PPKFS
Copy link
Contributor Author

PPKFS commented Jun 10, 2024

I was looking for a cabal test equivalent and didn't think to check for a makefile. Oops.

@jespercockx jespercockx merged commit 0fc20cc into agda:master Jul 10, 2024
7 checks passed
@PPKFS PPKFS deleted the issue-125-zurihac branch July 12, 2024 10:38
@jespercockx jespercockx linked an issue Jul 27, 2024 that may be closed by this pull request
@jespercockx jespercockx added this to the 1.3 milestone Sep 24, 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 this pull request may close these issues.

Check that constructors are not overloaded
2 participants