fix: check array size symbol kind
When determining the size of an array and a symbol is found, the symbol must be a const for the type to be valid. While it makes sense for this check to be done in type checking, the type can be determined by GTA which would then fail. For now this check is done when getting the node type. Fixes #825
This commit is contained in:
@@ -182,6 +182,9 @@ func nodeType(interp *Interpreter, sc *scope, n *node) (*itype, error) {
|
||||
t.size = arrayTypeLen(n.anc)
|
||||
default:
|
||||
if sym, _, ok := sc.lookup(n.child[0].ident); ok {
|
||||
if sym.kind != constSym {
|
||||
return nil, n.child[0].cfgErrorf("non-constant array bound %q", n.child[0].ident)
|
||||
}
|
||||
// Resolve symbol to get size value
|
||||
if sym.typ != nil && sym.typ.cat == intT {
|
||||
if v, ok := sym.rval.Interface().(int); ok {
|
||||
|
||||
Reference in New Issue
Block a user