y-lohse / inkjs

A javascript port of inkle's ink scripting language.
http://www.inklestudios.com/ink/
MIT License
489 stars 100 forks source link

fix: correctly handle empty INCLUDEs #1030

Closed floriancargoet closed 9 months ago

floriancargoet commented 9 months ago

Checklist

Description

This PR fixes a bug in the compiler with empty INCLUDEs.

Example:

// main.ink
INCLUDE a.ink
INCLUDE b.ink
{foo}

// a.ink (empty file)

// b.ink
VAR foo = "bar"

If you compile it with the inkjs.Compiler and a correctly set-up JsonFileHandler, the story fails at run-time with Unresolved variable: foo. If a.ink is not empty (a single space character is enough), everything works as expected.

This bug is caused by a falsy value ("") not taking the correct branch in an if statement if (includedString). This PR fixes that if with a stricter check: if (includedString != null).