Skip to content

Commit

Permalink
internal: Ensure to only pass TYPEINI trees to astTypeIniFlush()
Browse files Browse the repository at this point in the history
  • Loading branch information
dkl committed May 14, 2015
1 parent e0f3751 commit 556f290
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/compiler/ast-node-typeini.bas
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ function astTypeIniFlush overload _

dim as ASTNODE ptr n = any, nxt = any, t = any, l = any

assert( astIsTYPEINI( initree ) )
assert( astIsVAR( target ) or astIsDEREF( target ) or _
astIsFIELD( target ) or astIsIDX( target ) )

Expand Down Expand Up @@ -475,6 +476,10 @@ function astTypeIniFlush overload _
case AST_NODECLASS_TYPEINI_CTORLIST
t = hCallCtorList( t, n, target )

case AST_NODECLASS_TYPEINI_SCOPEINI, AST_NODECLASS_TYPEINI_SCOPEEND

case else
assert( FALSE )
end select

nxt = n->r
Expand Down
9 changes: 3 additions & 6 deletions src/compiler/parser-decl-var.bas
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,7 @@ private function hVarInitDefault _
'' because that's the only way for the coder to set the value.
if( typeIsConst( symbGetFullType( sym ) ) ) then
errReport( FB_ERRMSG_AUTONEEDSINITIALIZER )
'' error recovery: fake an expr
return astNewCONSTi( 0 )
exit function
end if

'' Has default constructor?
Expand Down Expand Up @@ -810,8 +809,7 @@ private function hVarInit _
'' ...or const-qualified vars
if( typeIsConst( symbGetFullType( sym ) ) ) then
errReport( FB_ERRMSG_AUTONEEDSINITIALIZER )
'' error recovery: fake an expr
return astNewCONSTi( 0 )
return NULL
end if

lexSkipToken( )
Expand All @@ -820,8 +818,7 @@ private function hVarInit _

initree = cInitializer( sym, FB_INIOPT_ISINI )
if( initree = NULL ) then
'' fake an expression
initree = astNewCONSTi( 0 )
return NULL
end if

'' static or shared?
Expand Down

0 comments on commit 556f290

Please sign in to comment.