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

Misleading error when custom type names partially overlap #127

Open
ngua opened this issue Jun 24, 2024 · 0 comments
Open

Misleading error when custom type names partially overlap #127

ngua opened this issue Jun 24, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ngua
Copy link
Contributor

ngua commented Jun 24, 2024

It seems that if custom type names partially overlap, using moduleQuoter with the custom types throws a very misleading error

I discovered this while trying to add a modelName type to the inferno-ml Prelude. I first tried:

customTypes :: [CustomType]
customTypes = ["tensor", "model", "modelName", "write"]

As you can see, modelName follows model. Then, I tried adding the following to mlQuoter (i.e moduleQuoter customTypes):

  ...

  loadModel : modelName -> model := ###!loadModelFun###;

This led to the following compile-time exception:

src/Inferno/ML/Module/Prelude.hs:192:13: error:
    • Error at line 252 column 3
        unexpected 'l'
        expecting one of the following:
        ∙ "module"
        ∙ end of input

    • In the quasi-quotation:
        [mlQuoter|
...

The error message misleadingly implies that there is a parse error; however, the problem is that modelName follows model, I assume this leads to some ambiguity. Changing the order of the customTypes to [..., "modelName", "model", ...] resolved the error, although this was very difficult to debug!

@ngua ngua added the bug Something isn't working label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant