Fix five defects the port uncovered in the reference parser and scanner
Chained subtraction and exponentiation fold left instead of abandoning the rest of the line -- `1 - 2 - 3` gave -1 and dropped the `- 3`. A unary leaf's operand moves to .left, so a negative literal is one argument again and a second argument no longer overwrites it. An operator in a line's final column survives. Hex literals reach the parser whole. A leading zero is padding, not a radix. Item 16 stays pinned: the fix works and costs an upstream golden case, which is a decision rather than a defect. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -377,8 +377,8 @@ static akerr_ErrorContext *parse_line_range(akbasic_Runtime *obj, akbasic_ASTLea
|
||||
}
|
||||
if ( expr->right->leaftype == AKBASIC_LEAF_UNARY &&
|
||||
expr->right->operator_ == AKBASIC_TOK_MINUS ) {
|
||||
/* -n: from the start through n. */
|
||||
PASS(errctx, akbasic_runtime_evaluate(obj, expr->right->right, &value));
|
||||
/* -n: from the start through n. A unary leaf's operand is on .left. */
|
||||
PASS(errctx, akbasic_runtime_evaluate(obj, expr->right->left, &value));
|
||||
FAIL_NONZERO_RETURN(errctx, (value->valuetype != AKBASIC_TYPE_INTEGER), AKBASIC_ERR_TYPE,
|
||||
"Expected a line number range");
|
||||
*endidx = value->intval;
|
||||
|
||||
Reference in New Issue
Block a user