From a9fb6978f8901cd0042c4ce236da453c32853fbc Mon Sep 17 00:00:00 2001 From: zhiayang Date: Thu, 27 Jun 2019 00:19:10 +0800 Subject: [PATCH] oops, fixed the if-thing again. --- build/ultratiny.flx | 1 - source/frontend/parser/controlflow.cpp | 9 +++++---- source/typecheck/directives.cpp | 4 +--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/build/ultratiny.flx b/build/ultratiny.flx index a374b771..25f439ed 100644 --- a/build/ultratiny.flx +++ b/build/ultratiny.flx @@ -7,7 +7,6 @@ export ultratiny import libc import std::math - var value = 401.0 #if value > 30.0 diff --git a/source/frontend/parser/controlflow.cpp b/source/frontend/parser/controlflow.cpp index c537eb4f..37bbcad1 100644 --- a/source/frontend/parser/controlflow.cpp +++ b/source/frontend/parser/controlflow.cpp @@ -100,15 +100,11 @@ namespace parser c.body = parseBracedBlock(st); cases.push_back(c); - - if(isStaticIf) c.body->doNotPushNewScope = true; } else if(st.frontAfterWS() == TT::LBrace || st.frontAfterWS() == TT::FatRightArrow) { // ok, parse an else elseCase = parseBracedBlock(st); - if(isStaticIf) elseCase->doNotPushNewScope = true; - break; } else @@ -125,6 +121,11 @@ namespace parser ret->cases = cases; ret->elseCase = elseCase; + for(auto& c : ret->cases) + c.body->doNotPushNewScope = true; + + ret->elseCase->doNotPushNewScope = true; + return ret; } else diff --git a/source/typecheck/directives.cpp b/source/typecheck/directives.cpp index e49462ed..9b6fc47e 100644 --- a/source/typecheck/directives.cpp +++ b/source/typecheck/directives.cpp @@ -100,9 +100,7 @@ TCResult ast::IfDirective::typecheck(sst::TypecheckState* fs, fir::Type* infer) if(!execBlock) { - // ok we need to return a fake value. - auto ret = util::pool(this->loc, fir::Type::getVoid()); - return TCResult(ret); + return TCResult::getDummy(); } else {