haskell-suite / haskell-src-exts

Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer
Other
193 stars 94 forks source link

"Ambiguous infix expression" should be a ParseFailure, not an error #74

Open UnkindPartition opened 10 years ago

UnkindPartition commented 10 years ago
  1. applyFixities must return ParseResult and report the location of the fixity error
  2. In the AppFixity Exp instance, fail should be replaced with ParseFailure
  3. In InternalParser, use monadic composition when applying fixities.
UnkindPartition commented 10 years ago

Note that this is partially addressed by 9de7622334027eb07bb6e979e48d6fdf1fef7788.

But since we're continuing to use fail, we don't get locations for fixity errors.

gibiansky commented 9 years ago

Does applyFixities (the annotated version) have to take ASTs annotated with SrcSpanInfo, or would other annotations also work?

UnkindPartition commented 9 years ago

Good question.

One reason why applyFixities requires SrcSpanInfo annotations is because it constructs new AST nodes and has to come up with annotations for them. And it's not just a matter of using some default annotation — e.g. with SrcSpanInfo it has to merge the annotations of the children to compute the right span, see here.

The other reason is to be able to report the location of fixity errors, according to the plan above.

So, yes, it needs to be more or less SrcSpanInfo.