Skip to content

parsing identifier which name starts with reserved keyword #547

@semio

Description

@semio

Dhall fails to parse identifier when the identifier's name starts with a reserved keyword, for example:

➔ dhall <<< "let mergedRec = { a = 1 } // { b = 2 } in mergedRec"

Error: Invalid input

(stdin):2:1:
  |
2 | <empty line>
  | ^
unexpected end of input
expecting "!=", "&&", "++", "->", "//", "//\\", "/\", "==", "||", "", "", "", "", '#', '(', '*', '+', '.', '?', '@', built-in expression, double literal, import, integer literal, label, list literal, natural literal, record type or literal, text literal, the rest of label, or union type or literal

But it works if I rename the variable name

➔ dhall <<< "let _mergedRec = { a = 1 } // { b = 2 } in _mergedRec"
{ b = 2, a = 1 }

Also I found dhall format gives incorrect result when the identifier starts with constructors:

➔ dhall format <<< "let constructorsRec = { a = 1, b = 2 } in constructorsRec"
let constructorsRec = { a = 1, b = 2 } in constructors Rec    
##                                                    ^ a space was inserted

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions