inkle / ink

inkle's open source scripting language for writing interactive narrative.
http://www.inklestudios.com/ink
MIT License
4.14k stars 495 forks source link

Tunnel Return-Divert crashes compiler when going to a variable #765

Closed tustin2121 closed 5 months ago

tustin2121 commented 2 years ago

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
joethephish commented 5 months ago

Not crashing (anymore?) in latest