Skip to content

Commit f733ffb

Browse files
Merge pull request #2513 from sensei-hacker/fix-transpiler-qodo-issues
Fix transpiler conflict detection and AST consistency
2 parents 40402fe + 50001fd commit f733ffb

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

js/transpiler/transpiler/analyzer.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -525,12 +525,9 @@ class SemanticAnalyzer {
525525
let stmtIndex = 0;
526526
for (const stmt of ast.statements) {
527527
if (stmt && stmt.type === 'EventHandler') {
528-
// Each if statement gets a unique key - we want to detect multiple
529-
// assignments within the SAME if block, not across different if
530-
// statements that happen to have the same condition
531-
const handlerKey = stmt.handler === 'ifthen' ?
532-
`ifthen:${stmtIndex}` :
533-
stmt.handler;
528+
// Each handler gets a unique key - we want to detect multiple
529+
// assignments within the SAME handler, not across different handlers
530+
const handlerKey = `${stmt.handler}:${stmtIndex}`;
534531

535532
if (!handlerAssignments.has(handlerKey)) {
536533
handlerAssignments.set(handlerKey, new Map());

js/transpiler/transpiler/condition_generator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,14 @@ class ConditionGenerator {
297297
return this.generateBinary({
298298
...condition,
299299
operator: '>',
300-
right: constValue - 1
300+
right: { type: 'Literal', value: constValue - 1 }
301301
}, activatorId);
302302
} else {
303303
// x <= 5 → x < 6
304304
return this.generateBinary({
305305
...condition,
306306
operator: '<',
307-
right: constValue + 1
307+
right: { type: 'Literal', value: constValue + 1 }
308308
}, activatorId);
309309
}
310310
}

0 commit comments

Comments
 (0)