diff options
author | Elliott Sales de Andrade <[email protected]> | 2023-08-28 04:19:19 -0400 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-09-10 23:14:58 +0200 |
commit | bf73516259b3028ade4b9e48499e988523f52542 (patch) | |
tree | 0dee2fb98c508adb80f3ee7964815669e2cf45f8 /compiler | |
parent | 43d282174fe37c5606c2f438757b6fdaed13f61a (diff) | |
download | tinygo-bf73516259b3028ade4b9e48499e988523f52542.tar.gz tinygo-bf73516259b3028ade4b9e48499e988523f52542.zip |
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
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/compiler.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/compiler.go b/compiler/compiler.go index 6dd43935a..cb3a892a8 100644 --- a/compiler/compiler.go +++ b/compiler/compiler.go @@ -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. |