MyWorldLLC/Chipmunk

Broken self-resolution in for loops

Closed this issue · 1 comments

The following code should compile:

for(key in data){
    duplicate.data[key] = data[key]
}

However, compilation fails with:

java.lang.IllegalStateException: data is not a local
	at chipmunk.compiler.codegen.Codegen.emitLocalReference(Codegen.java:125)
	at chipmunk.compiler.codegen.Codegen.emitLocalAccess(Codegen.java:108)
	at chipmunk.compiler.codegen.ExpressionVisitor.visit(ExpressionVisitor.java:66)
...

Manually re-writing the code to:

for(key in self.data){
    duplicate.data[key] = data[key]
}

works, meaning that the AST rewrite for resolving instance variables is not working for the operand in the for-loop.

Fixed by 9291886.