Skip to content

Compiler crashes when diverting to choice or gather labels with parameters #208

@benabutler

Description

@benabutler

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

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions