diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-05-14 13:38:53 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-05-14 13:38:53 -0400 |
| commit | 495a597ef6b3e9398f6a757713ec4137affd9152 (patch) | |
| tree | 40a5f0216360763a60de297485d3d2b786c6086b /typecheck.c | |
| parent | 1924f75647389003873c4532449484c65c83e79b (diff) | |
Better error messages
Diffstat (limited to 'typecheck.c')
| -rw-r--r-- | typecheck.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/typecheck.c b/typecheck.c index 139da0b6..7825c692 100644 --- a/typecheck.c +++ b/typecheck.c @@ -231,7 +231,9 @@ void bind_statement(env_t *env, ast_t *statement) type_t *field_t = get_arg_ast_type(env, field_ast); if ((field_t->tag == StructType && Match(field_t, StructType)->opaque) || (field_t->tag == EnumType && Match(field_t, EnumType)->opaque)) - code_err(field_ast->type, "This type is recursive and would create an infinitely sized struct. Try using a pointer."); + code_err(field_ast->type, "I'm still in the process of defining the fields of %T, so I don't know how to use it as a member." + "\nTry using a @%T pointer for this field or moving the definition of %T before %T in the file.", + field_t, field_t, field_t, type); fields = new(arg_t, .name=field_ast->name, .type=field_t, .default_val=field_ast->value, .next=fields); } REVERSE_LIST(fields); @@ -262,7 +264,9 @@ void bind_statement(env_t *env, ast_t *statement) type_t *field_t = get_arg_ast_type(env, field_ast); if ((field_t->tag == StructType && Match(field_t, StructType)->opaque) || (field_t->tag == EnumType && Match(field_t, EnumType)->opaque)) - code_err(field_ast->type, "This type is recursive and would create an infinitely sized struct. Try using a pointer."); + code_err(field_ast->type, "I'm still in the process of defining the fields of %T, so I don't know how to use it as a member." + "\nTry using a @%T pointer for this field or moving the definition of %T before %T in the file.", + field_t, field_t, field_t, type); fields = new(arg_t, .name=field_ast->name, .type=field_t, .default_val=field_ast->value, .next=fields); } REVERSE_LIST(fields); |
