Skip to content

Misleading error when custom type names partially overlap  #127

Description

@ngua

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions