improve invalid array expression message

add AnyType array element to prevent cascading errors
This commit is contained in:
Dave Holoway
2020-06-07 15:59:12 +01:00
parent 20831c2326
commit 4750212484

View File

@@ -1702,7 +1702,8 @@ function arrayElementOrConstructor(tokens, open_array, matches, index) {
const types = matches.types.map(t => t instanceof ArrayType ? new ArrayType(t.base, t.arrdims+1) : new ArrayType(t, 1)); const types = matches.types.map(t => t instanceof ArrayType ? new ArrayType(t.base, t.arrdims+1) : new ArrayType(t, 1));
if (!variables[0] && !types[0]) { if (!variables[0] && !types[0]) {
addproblem(tokens, ParseProblem.Error(open_array, `Invalid array expression`)); addproblem(tokens, ParseProblem.Error(open_array, `Invalid array expression: '${matches.source}' is not an array type`));
variables.push(new ArrayElement(new Value(matches.source, new ArrayType(AnyType.Instance, 1)), index));
} }
return new ResolvedIdent(ident, variables, [], types); return new ResolvedIdent(ident, variables, [], types);
} }