mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
compiler: don't crash when encountering types.Invalid
This commit fixes a crash when trying to compile the following (invalid)
code:
package main
import "unsafe"
func main() {
}
type Foo struct {
x DoesNotExist
}
const foo = unsafe.Sizeof(Foo{})
This commit fixes this situation. The result is a regular error message,
indicating that DoesNotExist is not defined.
This commit is contained in:
committed by
Ron Evans
parent
a5a90a57b9
commit
a4fa41b49d
@@ -110,6 +110,9 @@ func (s *StdSizes) Sizeof(T types.Type) int64 {
|
||||
if k == types.UnsafePointer {
|
||||
return s.PtrSize
|
||||
}
|
||||
if k == types.Invalid {
|
||||
return 0 // only relevant when there is a type error somewhere
|
||||
}
|
||||
panic("unknown basic type: " + t.String())
|
||||
case *types.Array:
|
||||
n := t.Len()
|
||||
|
||||
Reference in New Issue
Block a user