This is always how it has worked, now a proper error is actually
reported.
[ ] :: should not declare a local variable, just bind a name to an expression.
They can still be lexically scoped.
- [ ] Currently accessing a field directly on a function call produces invalid
+ [X] Currently accessing a field directly on a function call produces invalid
WASM code; i.e. foo().bar; This should at least produce an error until
the underlying issue is fixed.
// NOTE: Useful inlined functions
static inline b32 is_lval(AstNode* node) {
return (node->kind == Ast_Kind_Local)
+ || (node->kind == Ast_Kind_Param)
|| (node->kind == Ast_Kind_Global)
|| (node->kind == Ast_Kind_Dereference)
|| (node->kind == Ast_Kind_Array_Access)
return 1;
}
+ if (!is_lval((AstNode *) field->expr)) {
+ onyx_report_error(field->token->pos,
+ "Cannot access field '%b'. Expression is not an lval.",
+ field->token->text,
+ field->token->length);
+ return 1;
+ }
+
StructMember smem;
if (field->token != NULL && field->field == NULL) {
token_toggle_end(field->token);