Skip to content

Commit a30c1fe

Browse files
committed
create unique method name to avoid conflict
1 parent 86f2bbe commit a30c1fe

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/parser.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,12 @@ TypeEnum::TypeEnum(const std::map<std::string, int> &names)
104104
}
105105
values[n.second] = new ConstantStringExpression(n.first);
106106
}
107-
f->statements.push_back(new AssignmentStatement(0, std::vector<const ReferenceExpression *>{new VariableExpression(name_array)}, new ArrayLiteralExpression(TYPE_STRING, values)));
107+
std::vector<const ReferenceExpression *> a;
108+
a.push_back(new VariableExpression(name_array));
109+
f->statements.push_back(new AssignmentStatement(0, a, new ArrayLiteralExpression(TYPE_STRING, values)));
108110
f->statements.push_back(new ReturnStatement(0, new ArrayIndexExpression(TYPE_STRING, new VariableExpression(name_array), new VariableExpression(fp))));
109111
methods["to_string"] = f;
110-
Parser::global_scope->addName("enum.to_string", f, true);
112+
Parser::global_scope->addName("enum.to_string."+std::to_string(reinterpret_cast<intptr_t>(this)), f, true);
111113
}
112114
}
113115

t/enum3.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
TYPE Colour := ENUM red green blue END ENUM
2+
TYPE Size := ENUM small medium large END ENUM

0 commit comments

Comments
 (0)