DavidKinder / Inform6

The latest version of the Inform 6 compiler, used for generating interactive fiction games.
http://inform-fiction.org/
Other
199 stars 32 forks source link

Unclosed double-quote at the end of a source file hangs the compiler #218

Closed erkyrath closed 1 year ago

erkyrath commented 1 year ago

Compiling this file:

[ Main;];
"hello

...leads to a compiler hang. The lexer is looping forever, adding nulls (or something) to the token buffer.

In the old days this would result in a MAX_QTEXT_SIZE memory limit error, but we got rid of those, whoops...

If you change the quote to a single quote, you instead get:

Error: Too much text for one pair of quotations '...' to hold

This implies that it's still getting into a loop but hitting a dict word length limit. (Hard-coded to 64 for some reason -- should that be MAX_DICT_WORD_SIZE? Something, anyway.)

Looks like a long-standing confusion about whether get_next_char() (the two functions of that name) return 0 or EOF on end-of-file.

erkyrath commented 1 year ago

The compiler silently treats a null byte as end-of-file, which I grudgingly admit is a bug -- it should complain about an illegal control character.

So I guess the answer is that get_next_char() should return EOF (-1) on end-of-file.

erkyrath commented 1 year ago

Actually I changed my mind about that. See PR.