diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-09-01 12:43:08 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-09-01 12:43:08 -0400 |
| commit | 0a7062e2d711b5ac7fb71e873f293a8f0d0e8bc6 (patch) | |
| tree | 912ae69dd9906dee11424433ff5367237296b0f6 /src/compile/optionals.c | |
| parent | 5fc7577b5a3bc2c445522dfd5b287e1c6eddc3e9 (diff) | |
Improved error messages
Diffstat (limited to 'src/compile/optionals.c')
| -rw-r--r-- | src/compile/optionals.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/compile/optionals.c b/src/compile/optionals.c index b3d94005..f32e925e 100644 --- a/src/compile/optionals.c +++ b/src/compile/optionals.c @@ -8,6 +8,7 @@ #include "../typecheck.h" #include "../types.h" #include "compilation.h" +#include "indexing.h" Text_t optional_into_nonnone(type_t *t, Text_t value) { if (t->tag == OptionalType) t = Match(t, OptionalType)->type; @@ -122,6 +123,7 @@ Text_t compile_optional(env_t *env, ast_t *ast) { public Text_t compile_non_optional(env_t *env, ast_t *ast) { ast_t *value = Match(ast, NonOptional)->value; + if (value->tag == Index && Match(value, Index)->index != NULL) return compile_indexing(env, value, true); type_t *t = get_type(env, value); Text_t value_code = compile(env, value); int64_t line = get_line_number(ast->file, ast->start); @@ -129,6 +131,6 @@ Text_t compile_non_optional(env_t *env, ast_t *ast) { check_none(t, Text("opt")), ")\n", "#line ", String(line), "\n", "fail_source(", quoted_str(ast->file->filename), ", ", String((int64_t)(value->start - value->file->text)), ", ", String((int64_t)(value->end - value->file->text)), ", ", - "\"This was expected to be a value, but it's none\");\n", optional_into_nonnone(t, Text("opt")), + "\"This was expected to be a value, but it's `none`\\n\");\n", optional_into_nonnone(t, Text("opt")), "; })"); } |
