Skip to content

Conversation

@willvale
Copy link
Contributor

Allow type conversion on redefine if the casting matrix says the types have a common base.
Allow bool->float conversion.

This fixes the following ink:

VAR b = true    
VAR i = 1
VAR f = 1.0

Initial values: {b} {i} {f}
Evaluated: {b+0.5} {i+0.5} {f+0.5}
~b = b + 0.5
~i = i + 0.5
~f = f + 0.5
Assigned: {b} {i} {f}
->DONE

Spotted because I have a global in my story which starts at zero (so is exported as an integer type) and later I add a float to it, at which point the inkcpp runtime falls over, whereas the C# runtime will coerce the type to the destination if possible.

This passed all the tests for me, and probably needs a new inkcpp or ink-proof test? I'm not sure if the casting matrix query I added is too permissive, but it does fail if e.g. you try and redefine a divert variable to a numeric type, which matches C# runtime behaviour.

Allow type conversion on redefine if the casting matrix says the types have a common base.
Allow bool->float conversion.
@JBenda
Copy link
Owner

JBenda commented Nov 23, 2025

Thanks for spotting this, since ink-proof is outside of our control a test in our test suit would be good in the beginning

I could do it or help you if this is your preferred way.

@willvale
Copy link
Contributor Author

Quite happy to add a test case to e.g. Fixes. Do you want it refer to the PR or to a new ticket?

@JBenda
Copy link
Owner

JBenda commented Nov 25, 2025

Yes just put it in this PR.

If you put a ink file inside inkcpp_test/ink it will be compiled in the cmake setup stage.

If you add a new test source file it needs to be added manually in inkcpp_test/Cmake list.txt

@willvale
Copy link
Contributor Author

Got all that working, I will update CMake, just chasing some list <> thing conversions which aren't supported (but are in C#)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants