The expression Int a = 1 / "x" will show two type errors at the moment.

This should only give an error on 1 / "x".

A fix would involve looking at failing dependencies.

Plus(x, y) : y-ty
where x : x-ty
  and y : y-ty
  and x-ty == y-ty else error $[Type mismatch: expected [x-ty] got [y-ty] in Addition] on y only if x-ty and y-ty succeed
Submitted by Daco Harkes on 11 March 2014 at 14:40

On 11 March 2014 at 15:28 Daco Harkes commented:

Related to cascaded type errors is if a failed name resolution triggers a type error; Int x = y with y undefined.

Multiple messages:
- Type mismatch: expected Int got in Derivation
- Unresolved reference

Note: “expected Int got in Derivation” shows an empty string on the failed type between got and in.


On 24 November 2014 at 16:28 Daco Harkes commented:

This error is annoying when TS is actually being used in a language.


On 29 November 2014 at 19:20 Daco Harkes tagged usability

On 19 May 2015 at 22:55 Jeff Smits tagged !jeffsmits

On 29 May 2015 at 02:40 Jeff Smits commented:

You can catch this in the message prettyprinter. For example, I’m using this code in Green Marl:

// Source: https://yellowgrass.org/issue/TS/2#showText416aa302157a6f217b48ca594cb7e9f9
  pp-message-top = origin-track-forced((id, strip-annos; pp-message; html-escape))
  pp-message = map(pp-preprocess(fail);pp-message-part); concat-strings
  // note the cascaded strategy can be something like !"<dep-fail>" for a placeholder message to go through, 
  //  or fail to keep the message from being printed 
  pp-preprocess(cascaded) = [] < cascaded + try(\[a] -> a\)
  pp-message-part = not(is-list); (is-string <+ pp-partial-Green-Marl-string <+ (strip-annos; write-to-string))
  pp-message-part = is-list; map(pp-message-part);separate-by(|", ") => l*; !["[",l*,"]"];concat-strings

  html-escape = string-replace(|"&","&amp;");string-replace(|"<","&lt;");string-replace(|">","&gt;")

On 29 May 2015 at 10:08 Daco Harkes commented:

Nice.

Yesterday there was a talk by Juriaan Hage on error diagnosis with constraint based typing.
Basically specifying priorities on the constraints (determining which constraint is solved first) and when an unsolvable constraint is encountered you display the message tied to that constraint: the else error from TS. Then you drop that constraint and continue solving, and repeat the process if you find another unsolvable constraint.

There are two ways of adding priorities to constraints:

  1. intra-rule: the constraint per type rule are ordered + inter-rule: phases: doing all type signatures before expressions - paper, another paper
  2. regular tree expressions: specify constraints over more than a single rule at the time (with recursion) - Juriaans work recently

Log in to post comments