Skip to content

Commit 090fa14

Browse files
committed
ast: Fix a casting error in CCOperation
1 parent c991ccc commit 090fa14

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/main/java/org/piccode/ast/CCOperationAst.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,21 @@ public String toString() {
4040
public PiccodeValue execute(Integer frame) {
4141
return Ast.safeExecute(frame, this, (expr) -> {
4242
if (lhs instanceof CCOperationAst op) {
43-
var mod = (PiccodeModule) op.execute(frame);
44-
if (!(rhs instanceof CallAst) && !(rhs instanceof IdentifierAst)) {
45-
throw new PiccodeException(file, line, column, "No node " + rhs + " found in module " + Chalk.on(mod.name).green());
43+
var result = op.execute(frame);
44+
if (result instanceof PiccodeModule mod) {
45+
if (!(rhs instanceof CallAst) && !(rhs instanceof IdentifierAst)) {
46+
throw new PiccodeException(file, line, column, "No node " + rhs + " found in module " + Chalk.on(mod.name).green());
47+
}
48+
49+
var id = new IdentifierAst(mod.name);
50+
id.file = file;
51+
id.line = line;
52+
id.column = column;
53+
return process(id, mod, frame);
54+
} else {
55+
return result;
4656
}
4757

48-
var id = new IdentifierAst(mod.name);
49-
id.file = file;
50-
id.line = line;
51-
id.column = column;
52-
return process(id, mod, frame);
5358
}
5459

5560
if (lhs instanceof IdentifierAst id && Context.top.getValue(id.text) != null) {

0 commit comments

Comments
 (0)