Skip to content

Commit 91eb3cf

Browse files
committed
[[ Bug 16033 ]] Throw when value is kMCExecValueTypeNone while evaling strict number
1 parent 6bfd45e commit 91eb3cf

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

docs/notes/bugfix-16033.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Empty converted to 0 in object id chunk expression
1+
# Ensure various forms of empty are not converted to 0 in object id expression

engine/src/exec.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,8 @@ static bool EvalExprAsStrictNumber(MCExecContext* self, MCExpression *p_expr, Ex
965965

966966
p_expr -> eval_ctxt(*self, t_value);
967967

968-
if (MCExecTypeIsValueRef(t_value . type) && MCValueIsEmpty(t_value . valueref_value))
968+
if (t_value . type == kMCExecValueTypeNone
969+
|| (MCExecTypeIsValueRef(t_value . type) && MCValueIsEmpty(t_value . valueref_value)))
969970
{
970971
self -> LegacyThrow(p_error);
971972

tests/lcs/core/execution/type-conversion.livecodescript

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,10 @@ on TestDoubleToUInt
2626
create button
2727
relayer it before layer 0.5
2828
TestAssert "round up positive reals in unsigned integer expressions", the layer of it is 1
29-
end TestDoubleToUInt
29+
end TestDoubleToUInt
30+
31+
on TestStrictUInt
32+
create button
33+
local tEmpty
34+
TestAssert "empty variable does not convert to 0 in object ID", not exists(button id tEmpty)
35+
end TestStrictUInt

0 commit comments

Comments
 (0)