racket / typed-racket

Typed Racket
Other
525 stars 105 forks source link

truly surprising error message from TR #779

Open jbclements opened 6 years ago

jbclements commented 6 years ago

What version of Racket are you using?

Welcome to DrRacket, version 7.0.0.20--2018-09-12(-/f) [3m].

What program did you run?

This student program:

#lang typed/racket

(define (subst [ft: BTree] [sy : Symbol] [rt : BTree])
  (match ft
    [(Node l r) (Node (subst l sy rt) (subst r sy rt))]
    [(Leaf sy) rt]
    [(Leaf s) (Leaf s)]))

What should have happened?

An error message highlighting some larger area, and text that makes a bit more sense.

If you got an error message, please include it here.

The highlighted region is the [sy : Symbol], and the error message is as follows:

define: expected more terms starting with expression parsing context: while parsing optional lambda argument while parsing lambda-formals while parsing curried-formals in: (sy : Symbol)

(yes, I see what the actual error is... but honestly, I think the only plausible way to diagnose this error is to stare at the program until you see the problem.)

rfindler commented 6 years ago

Maybe add a check for identifiers that end with colons (in error cases)?

On Mon, Oct 1, 2018 at 3:56 PM John Clements notifications@github.com wrote:

What version of Racket are you using?

Welcome to DrRacket, version 7.0.0.20--2018-09-12(-/f) [3m]. What program did you run?

This student program:

lang typed/racket

(define (subst [ft: BTree] [sy : Symbol] [rt : BTree]) (match ft [(Node l r) (Node (subst l sy rt) (subst r sy rt))] [(Leaf sy) rt] [(Leaf s) (Leaf s)]))

What should have happened?

An error message highlighting some larger area, and text that makes a bit more sense. If you got an error message, please include it here.

The highlighted region is the [sy : Symbol], and the error message is as follows:

define: expected more terms starting with expression parsing context: while parsing optional lambda argument while parsing lambda-formals while parsing curried-formals in: (sy : Symbol)

(yes, I see what the actual error is... but honestly, I think the only plausible way to diagnose this error is to stare at the program until you see the problem.)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/racket/typed-racket/issues/779, or mute the thread https://github.com/notifications/unsubscribe-auth/AAYWsGUOMeunF0kTaybMwZKexhC61r4lks5ugoFogaJpZM4XC32D .

jbclements commented 6 years ago

Yes, that's what I'm thinking.

maueroats commented 5 years ago

The error message for one argument with a mistake depends on whether or not that argument is followed by other arguments to the function. It would be nice if the argument with a mistake were successfully identified.

One Argument

The error message with one argument is ok:

#lang typed/racket

(define (example [x: Integer]) : Integer
  (+ x 5))

(example 8)

In Racket 7.3 highlights the term Integer and reports:

 type-check: type name used out of context
  type: Integer
  in: Integer in: Integer

Two Arguments

However, with two arguments, the situation is worse.

(define (example [x: Integer]
                 [y : Integer]) : Integer
  (+ x 5))

Gives a more opaque message:

define: expected more terms starting with expression
  parsing context: 
   while parsing optional lambda argument
   while parsing lambda-formals
   while parsing curried-formals in: (y : Integer)
maueroats commented 5 years ago

Recommend renaming issue:

TR error message when variable name ends with a colon does not identify problem area