ultra-group / skalpel

A type error slicer for Standard ML
GNU General Public License v3.0
10 stars 1 forks source link

Very confusing syntax error message for = instead of => in case expression #64

Open jpirie opened 10 years ago

jpirie commented 10 years ago

If you enter this program, TES highlights the indicated spot:

datatype t = A | B | C; fun f x = case x 1 2 3 4 5 6 7 of (A) = 1 | (B) = 2 (* ^^^ *) | (C) = 3;

The TES error message is this:

Error: Parsing problem (function name should be an identifier)

What is happening is that TES is thinking that the “|” might be starting another clause of the definition of f instead of another branch of the case expression.

SML/NJ in contrast more usefully identifies an error in the "=" after "(A)":

Error: syntax error: replacing EQUALOP with DARROW

(Of course, SML/NJ's error message also sucks because it assumes the reader knows what EQUALOP and DARROW are, but SML/NJ's message sucks much less.)

jpirie commented 10 years ago

(From bugzilla) Vincent Rahli: For now I've just changed the way some of our errors are handled at parsing time. What I've done is similar to what we do for non syntacticly correct infix expressions and patterns, I cache our error and wait and see if ml-yacc has an error to throw.

jpirie commented 10 years ago

(From bugzilla) Joe Wells: Thanks, Vincent!

By the way, are there other places where the same change perhaps should be made, or are they now all covered?