From 9ec503ac7121c1d7499515fcb765328e4f279377 Mon Sep 17 00:00:00 2001 From: Hackerpilot Date: Sun, 18 Jan 2015 03:44:36 -0800 Subject: [PATCH] Fix segfault with 'with' statements --- src/conversion/first.d | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/conversion/first.d b/src/conversion/first.d index 3aed36ba..e7621bc1 100644 --- a/src/conversion/first.d +++ b/src/conversion/first.d @@ -481,14 +481,17 @@ final class FirstPass : ASTVisitor Scope* s = allocate!Scope(semanticAllocator, withStatement.statementNoCaseNoDefault.startLocation, withStatement.statementNoCaseNoDefault.endLocation); - SemanticSymbol* symbol = allocateSemanticSymbol(WITH_SYMBOL_NAME, - CompletionKind.withSymbol, symbolFile, s.startLocation, null); s.parent = currentScope; currentScope.children.insert(s); - populateInitializer(symbol, withStatement.expression, false); + currentScope = s; + SemanticSymbol* symbol = allocateSemanticSymbol(WITH_SYMBOL_NAME, + CompletionKind.withSymbol, symbolFile, s.startLocation, null); symbol.parent = currentSymbol; - currentSymbol.addChild(symbol); + currentSymbol = symbol; + populateInitializer(symbol, withStatement.expression, false); withStatement.accept(this); + currentSymbol = currentSymbol.parent; + currentSymbol.addChild(symbol); currentScope = currentScope.parent; } else