Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly handle empty INCLUDEs #1030

Merged
merged 1 commit into from
Sep 27, 2023

Conversation

floriancargoet
Copy link
Contributor

Checklist

  • The new code additions passed the tests (npm test).
  • The linter ran and found no issues (npm run-script lint).
    • Quelques warnings mais ils étaient là avant.

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).

@smwhr smwhr merged commit d6d53a6 into y-lohse:master Sep 27, 2023
1 check passed
@floriancargoet floriancargoet deleted the fix/empty-include branch September 27, 2023 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants