-
-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash from card with type mismatch #1301
Comments
Thanks for reporting! |
If other people have a similar issue: you can get around the type checking by doing the n1 = append([], arithmeticIncrement)
n2 = append(t1, 1.1d) -- the list we want to `apply` over
reduce_op(r, v) = append(r, apply(getLastListElement(r), v))
n3 = reduce(reduce_op, n2, [id])
n4 = getLastListElement(n3)
|
I don't know if this should be a new issue or still part of this issue, but there are operators other than those previously mentioned here still causes a crash. Even if operators that cause a crash like this should be considered and fixed individually (such as with the commit that fixed Stacktrace:
(tested in 1.20.1-1.18.0) |
Not easily I'm afraid. Unless we'd catch all ClassCastExceptions or RuntimeExceptions, but then we might be catching actual programming errors, which will open another whole can of worms. Let's just fix the |
Issue type:
Short description:
t3
from below causes a crash whenname(t3)
is placed in a display panel, or if a card is placed in the bottom slot of a materialiser whent3
is in the top slot (placingt3
in the top slot alone is fine).Steps to reproduce the problem:
Note that
t4 = add(t3, 7i)
in a display panel yields9.1d
as expected (i.e. it correctly detects that the two types areDouble
andInteger
, and outputsDouble
), howevername(t4)
also causes a crash.negation(t3)
results in the error 'Attempted to cast Double to Operator, for value "2.1"', but does not cause a crash (I'm not sure what the behaviour would otherwise be, so I guess this is as expected).The LP does not allow
negation(t4)
to be created, giving the error 'The operation negation received an input with type Number at position 1 while the type Operator was expected.'.From BlockEntityMaterializer.java#L113 (
final IValue value = variable.getType().materialize(variable.getValue());
) it looks like there might be a problem with thegetType
of the variable returning one thing (i.e.Operator
), but the actualgetValue
of the variable being a different type (e.g.Double
).Expected behaviour:
Either being consistent with
increment(t3)
at least partially working, i.e.:Materialising
t3
yields a card with the correct type and value (i.e. aDouble
card with value2.1
).name(t3)
yields the string"2.1"
(i.e. the same value asname(2.1d)
), and similar behaviour forname(t4)
.Or, any attempt to evaluate
t3
results in an error due to the incorrect typing:Any of placing
t3
in a display panel, placingincrement(t3)
in a display panel, or trying to materialiset3
yields an error like 'Attempted to cast Double to Operator, for value "2.1"' (the error displayed currently when trying to evaluatenegation(t3)
).Versions:
Log file:
(note: I have had a lot of crashes recently, so I'm fairly sure these are the correct crashes and that they are labelled correctly, but if something doesn't seem right I may have made a mistake)
https://pastebin.com/asTsNCBb - materialiser crash
https://pastebin.com/hzNsr9Yj -
name(t3)
crashhttps://pastebin.com/GAxqSMiZ -
name(t4)
crashThe text was updated successfully, but these errors were encountered: