mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 20:13:40 +00:00
compiler: Handle nil array and struct constants
This is necessary for tools 0.9.0, which started lifting those since https://github.com/golang/tools/commit/71ea8f168c160da91116b4ddbd577a8fc95aa334
This commit is contained in:
committed by
Ron Evans
parent
43d282174f
commit
bf73516259
@@ -3005,6 +3005,11 @@ func (c *compilerContext) createConst(expr *ssa.Const, pos token.Pos) llvm.Value
|
||||
panic("expected nil pointer constant")
|
||||
}
|
||||
return llvm.ConstPointerNull(c.getLLVMType(typ))
|
||||
case *types.Array:
|
||||
if expr.Value != nil {
|
||||
panic("expected nil array constant")
|
||||
}
|
||||
return llvm.ConstNull(c.getLLVMType(expr.Type()))
|
||||
case *types.Slice:
|
||||
if expr.Value != nil {
|
||||
panic("expected nil slice constant")
|
||||
@@ -3018,6 +3023,11 @@ func (c *compilerContext) createConst(expr *ssa.Const, pos token.Pos) llvm.Value
|
||||
llvmLen, // cap
|
||||
}, false)
|
||||
return slice
|
||||
case *types.Struct:
|
||||
if expr.Value != nil {
|
||||
panic("expected nil struct constant")
|
||||
}
|
||||
return llvm.ConstNull(c.getLLVMType(expr.Type()))
|
||||
case *types.Map:
|
||||
if !expr.IsNil() {
|
||||
// I believe this is not allowed by the Go spec.
|
||||
|
||||
Reference in New Issue
Block a user