mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-19 16:54:08 +10:00
Fixed logical AND and OR operators, read more
The definition of '&&': Return the first falsy value, or the last value, skipping the evaluation of other operands. The definition of '||': Return the first truthy value, or the last value, skipping the evaluation of other operands. Toy now follows these definitions. Fixed #154
This commit is contained in:
@@ -708,7 +708,13 @@ static void parsePrecedence(Toy_Bucket** bucketHandle, Toy_Parser* parser, Toy_A
|
||||
Toy_private_emitAstAggregate(bucketHandle, rootHandle, flag, ptr);
|
||||
}
|
||||
else {
|
||||
Toy_private_emitAstBinary(bucketHandle, rootHandle, flag, ptr);
|
||||
//BUGFIX: '&&' and '||' are special cases, with short-circuit logic
|
||||
if (flag == TOY_AST_FLAG_AND || flag == TOY_AST_FLAG_OR) {
|
||||
Toy_private_emitAstBinaryShortCircuit(bucketHandle, rootHandle, flag, ptr);
|
||||
}
|
||||
else {
|
||||
Toy_private_emitAstBinary(bucketHandle, rootHandle, flag, ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user