colis-anr / morbig

A static parser for POSIX Shell
Other
190 stars 8 forks source link

Morbig__PrelexerState.NotAWord("EOF") #80

Closed Niols closed 5 years ago

Niols commented 5 years ago

When given:

cat <<FOO
`
FOO

cat <<BAR
`
BAR

Morbig fails with

Fatal error: exception Morbig__PrelexerState.NotAWord("EOF")

When given only the first invalid document, it fails correctly, saying:

Line 4, character 0: Lexical error (Unterminated nesting!).
Niols commented 5 years ago

Actually, I can reproduce this exception with only:

java << EOD
yurug commented 5 years ago

dash -n accepts your example with java, bash produces a warning but accepts it.

AFAIK, POSIX does not explicitly say that an here-document can be ended by an EOF. So I will agree with you that this example must be rejected.

Niols commented 5 years ago

I don't know whether we should accept such a script or not. It might very well be unclear in the standard. However, failing with an exception shouldn't happen.

Niols commented 5 years ago

Or different versions of Yojson. I am using 1.5.0. I guess there is a dependency holding it back there, it might be more efficient in the 1.7.0 version. I'll give it a try and let you know.