From 72b6dc3de74f134232793d80103605c2501644d1 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 11 Oct 2020 00:37:35 +0200 Subject: [PATCH] avoid crash when optimizer has multiple replacements of the same node --- compiler/src/prog8/ast/statements/AstStatements.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/src/prog8/ast/statements/AstStatements.kt b/compiler/src/prog8/ast/statements/AstStatements.kt index c6cdabe1a..e82a6d2e2 100644 --- a/compiler/src/prog8/ast/statements/AstStatements.kt +++ b/compiler/src/prog8/ast/statements/AstStatements.kt @@ -235,7 +235,8 @@ open class VarDecl(val type: VarDeclType, } override fun replaceChildNode(node: Node, replacement: Node) { - require(replacement is Expression && node===value) + // TODO the check that node===value is too strict sometimes, but leaving it out allows for bugs to creep through ... :( Perhaps check when adding the replace if there is already a replace on the same node? + require(replacement is Expression) value = replacement replacement.parent = this }