-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
The error messages for unterminated strings are inconsistent, oddly formulated and sometimes point to the wrong point in the code. They are also untested, which led to #3379. I tried and failed to fix this myself in #3392.
-
A
'is not unexpected in these cases:$ coffee -pe "'" [stdin]:1:1: error: unexpected ' ' ^ $ coffee -pe "console.log 'foo" [stdin]:1:13: error: unexpected ' console.log 'foo ^ $ coffee -ps console.log 'foo console.log "bar" [stdin]:1:13: error: unexpected ' console.log 'foo ^ -
What does “, starting” mean?
$ coffee -pe '"' [stdin]:1:1: error: missing ", starting " ^ $ coffee -pe 'console.log "foo' [stdin]:1:13: error: missing ", starting console.log "foo ^ $ coffee -ps console.log "foo console.log 'bar' [stdin]:1:13: error: missing ", starting console.log "foo ^ -
These cases might seem unrelated to unterminated strings, but in a way they are. They were caused by the programmer forgetting to close the “foo” string of the first line. It also seems easy to mess this up; See Improve error messages for unterminated strings #3392. Also, the case with double quotes is wrong.
$ coffee -ps console.log 'foo console.log 'bar' [stdin]:2:14: error: unexpected bar console.log 'bar' ^^^ $ coffee -ps console.log "foo console.log "bar" [stdin]:2:17: error: missing ", starting console.log "bar" ^ -
In interpolations, all errors point to the same place. The pointer should be at either the opening or closing delimiter. Also notice that suddenly
'strings are expected, and the weird “missing X, starting” type of message is used instead.$ coffee -ps "#{'}" [stdin]:1:1: error: missing ', starting "#{'}" ^ $ coffee -ps "#{"}" [stdin]:1:1: error: missing }, starting "#{"}" ^ $ coffee -ps "#{foo '}" [stdin]:1:1: error: missing ', starting "#{foo '}" ^ $ coffee -ps "#{foo "}" [stdin]:1:1: error: missing }, starting "#{foo "}" ^