Skip to content

Commit c4309ab

Browse files
BeyondMagicCopilot
andauthored
fix(optimizer): differentiate between int literal and char literal
Co-authored-by: Copilot <[email protected]>
1 parent 6a10bf6 commit c4309ab

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/optimizer.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,12 @@ static char *expr_make_key(const AstExpr *expr)
530530
switch (expr->kind)
531531
{
532532
case EXPR_INT_LITERAL:
533-
snprintf(buffer, sizeof(buffer), "I:%lld", expr->data.int_value);
533+
// Include type information in the key to distinguish between int and char literals
534+
if (expr->type == TYPE_CHAR) {
535+
snprintf(buffer, sizeof(buffer), "C:%lld", expr->data.int_value);
536+
} else {
537+
snprintf(buffer, sizeof(buffer), "I:%lld", expr->data.int_value);
538+
}
534539
return dup_string(buffer);
535540
case EXPR_FLOAT_LITERAL:
536541
snprintf(buffer, sizeof(buffer), "F:%g", expr->data.float_value);

0 commit comments

Comments
 (0)