ink icon indicating copy to clipboard operation
ink copied to clipboard

Tunnel Return-Divert crashes compiler when going to a variable

Open tustin2121 opened this issue 3 years ago • 0 comments

The "Advanced feature" mentioned in Writing With Ink that says that you can return from a tunnel but divert elsewhere using the syntax ->-> target will crash the ink compiler with a NullReferenceException if that target is a variable. See the following story file:

VAR next_area = -> start
-> start

== start
Once upon a time...
~ next_area = ->ending
-> tunnel ->
Happily ever after
-> END

== ending
terrible time!
-> END

== tunnel
// Below line crashes compiler
->-> next_area

== otherTunnel
->-> ending

In Inky this results in the following exception presented in the story pane:

System.Exception: Object reference not set to an instance of an object. (Internal story path: start.6)
 ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Ink.Runtime.Story.PointerAtPath(Path path)
   at Ink.Runtime.Story.PerformLogicAndFlowControl(Object contentObj)
   at Ink.Runtime.Story.Step()
   at Ink.Runtime.Story.ContinueSingleStep()
   at Ink.Runtime.Story.ContinueInternal(Single millisecsLimitAsync)
   at Ink.CommandLinePlayer.EvaluateStory()
   at Ink.CommandLinePlayer.Begin()
   at Ink.CommandLineTool..ctor(String[] args)
   --- End of inner exception stack trace ---
   at Ink.CommandLineTool..ctor(String[] args)
   at Ink.CommandLineTool.Main(String[] args)</pre></div></div>

Fortunately, this can be worked around at the moment with the following edit:

== tunnel
->-> goto_next_area

== goto_next_area
-> next_area

tustin2121 avatar May 16 '22 13:05 tustin2121