inkle / inkle/ink

Compiler crashes when diverting to choice or gather labels with parameters

Open
#921 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.9k
Forks
540
PR merge metrics
No merged PRs in 30d

Description

If an ink file attempts to pass an argument while diverting to a choice or gather label, the compiler will crash with this stack:

```
Ink Compiler threw exception
Error: Object reference not set to an instance of an object
---- Trace ----
at Ink.Parsed.Divert.GenerateRuntimeObject () [0x000cb] in Assets\Ink\InkLibs\InkCompiler\ParsedHierarchy\Divert.cs:90
at Ink.Parsed.Object.get_runtimeObject () [0x00012] in Assets\Ink\InkLibs\InkCompiler\ParsedHierarchy\Object.cs:55
at Ink.Parsed.Weave.GenerateRuntimeObject () [0x0009b] in Assets\Ink\InkLibs\InkCompiler\ParsedHierarchy\Weave.cs:198
at Ink.Parsed.Object.get_runtimeObject () [0x00012] in Assets\Ink\InkLibs\InkCompiler\ParsedHierarchy\Object.cs:55
at Ink.Parsed.FlowBase.GenerateRuntimeObject () [0x0019f] in Assets\Ink\InkLibs\InkCompiler\ParsedHierarchy\FlowBase.cs:247
at Ink.Parsed.Object.get_runtimeObject () [0x00012] in Assets\Ink\InkLibs\InkCompiler\ParsedHierarchy\Object.cs:55
at Ink.Parsed.FlowBase.GenerateRuntimeObject () [0x000eb] in Assets\Ink\InkLibs\InkCompiler\ParsedHierarchy\FlowBase.cs:217
at Ink.Parsed.Object.get_runtimeObject () [0x00012] in Assets\Ink\InkLibs\InkCompiler\ParsedHierarchy\Object.cs:55
at Ink.Parsed.Story.ExportRuntime (Ink.ErrorHandler errorHandler) [0x0013b] in Assets\Ink\InkLibs\InkCompiler\ParsedHierarchy\Story.cs:155
at Ink.Compiler.Compile () [0x00085] in Assets\Ink\InkLibs\InkCompiler\Compiler.cs:53
at Ink.UnityIntegration.InkCompiler.CompileInkThreaded (System.Object itemObj) [0x00085] in Assets\Ink\Editor\Core\Compiler\InkCompiler.cs:576
--------
```

It looks to me like the Divert.GenerateRuntimeObject assumes targetContent will be a FlowBase if the user is providing arguments, but gathers and choices are just regular Ink.Parsed.Object objects. I don't think passing arguments to a gather point is valid Ink syntax - I only hit the crash because I mistyped something - but the compiler should probably provide a nice error message like it does for diverting with parameters to knots that don't take parameters.

Here's a repro demonstrating the behavior:
[InkCompilerCrashRepro.txt](https://github.com/user-attachments/files/18003077/InkCompilerCrashRepro.txt)

I found this issue on v1.2.0 while using the ink-unity-integration plugin v1.2.1, but also reproduced it on a standalone build of inky v1.1.0. Originally filed in the unity plugin repo here: https://github.com/inkle/ink-unity-integration/issues/208

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.