YarnSpinnerTool / YarnSpinner

Yarn Spinner is a tool for building interactive dialogue in games!
https://yarnspinner.dev
MIT License
2.3k stars 201 forks source link

.YarnProject fails import when inferring variable type as integer via increment #338

Closed fmoo closed 11 months ago

fmoo commented 1 year ago

What is the current behavior?

When implicitly defining a variable through its usage a certain way, the .yarnproject will fail to import and cause various runtime errors. The compile itself fails with a generic error that could also be improved.

Please provide the steps to reproduce, and if possible a minimal demo of the problem:

Create a .yarn file with the following contents:

title: Bug3
---
<<set $akos_talkers = $akos_talkers + 1>>
===

image

What is the expected behavior?

$akos_talkers should be detected as an integer, and the .yarnproject compiles

Please tell us about your environment:

Other information

vlanf commented 1 year ago

I think declare should help:

title: Bug3
---
<<declare $akos_talkers = 0 as int>>
<<set $akos_talkers = $akos_talkers + 1>>
===
McJones commented 11 months ago

There are two parts to this bug, the first is that the type inference isn't working correctly. This is fixed in the WIP line groups branch which has a much more rigorous type system. The second is it crashes the import at Unity, this is fixed in https://github.com/YarnSpinnerTool/YarnSpinner-Unity/commit/6d5054b993f9b77cf034885e60fd04eebc6d3225

Closing this now, thanks for finding it.