Skip to content

Commit

Permalink
Empty slices can be instantiated in variable declaration time.
Browse files Browse the repository at this point in the history
  • Loading branch information
markkurossi committed Jul 25, 2024
1 parent 4698602 commit 6a74b45
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions compiler/ast/ssagen.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,13 @@ func (ast *VariableDef) SSA(block *ssa.Block, ctx *Codegen,
return nil, nil, ctx.Errorf(ast, "undefined variable")
}
if !typeInfo.Concrete() {
return nil, nil, ctx.Errorf(ast.Type,
"unspecified size for type %v", ast.Type)
if typeInfo.Type != types.TSlice {
return nil, nil, ctx.Errorf(ast.Type,
"unspecified size for type %v", ast.Type)
}
// Empty slices can be instantiated in variable
// declaration time.
typeInfo.SetConcrete(true)
}
initVal, err := initValue(typeInfo)
if err != nil {
Expand Down

0 comments on commit 6a74b45

Please sign in to comment.