unpredictable type inference #60
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
when variables are assigned values from
HInterface.expr()they sometimes inconveniently infer the wrong types and change the values, i.e. stringifying objects. This behavior varies across target platforms, which could cause some tremendous issues if people use hscript in their stories for more than basic string/number manipulation. Be cautious.This issue forced me to make
"true"and"false"(string values) coerce to booleans in a workaround for C++ test coverage:3d99159102/hank/HInterface.hx (L77)If I decide to probe into this deeper, one thing I didn't think to do was check into how exactly the compiled C++ code looks. That could answer a few questions, if not suggest a solution.
Potentially relevant:
https://code.haxe.org/category/other/passing-different-types-to-a-function-parameter.html
https://haxe.org/manual/type-system-type-parameters.html
https://haxe.org/manual/type-system-unification.html
The solution I've had bouncing around my head is that I could transmute assignment operations to actually store the hscript
Exprof the assigned value, and when type info is needed on a variable, consult the expr. This would require transmuting lots of other expressions (such as dot access) to unwrap the value from the Expr before operating on it. Maybe another approach, would be to keep a type dictionary inside the hinterface? That might be crazy given that we can consult types at runtime. I'm getting in the weeds with this problem.I'm wondering whether a Value type like Ink's might help out in this case.
https://haxetink.github.io/tink_core/#/types/any
I wonder if just writing
Story.getVariable()to returnAnyvalues would avoid these potential problems.