mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Improve error messages on expressions like var $type = int; #1553.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
- Infer now works across ternary.
|
||||
- Interfaces now support .ptr and .type directly without casting to `any`.
|
||||
- Switch to `<* *>` docs.
|
||||
- Improve error messages on expressions like `var $type = int;` #1553.
|
||||
|
||||
### Fixes
|
||||
- `Unsupported int[*] $x = { 1, 2, 3, 4 }` #1489.
|
||||
@@ -35,6 +36,7 @@
|
||||
- Standard library is now correctly weakly linked, fixing the use of C3 .so together with executable. #1549, #1107.
|
||||
- Wrong error message for interface methods with body #1536.
|
||||
- Empty expression block would crash compiler with debug on #1554.
|
||||
|
||||
### Stdlib changes
|
||||
- Remove unintended print of `char[]` as String
|
||||
- Add read/write to stream with big endian ints.
|
||||
|
||||
@@ -3746,6 +3746,11 @@ bool sema_analyse_var_decl_ct(SemaContext *context, Decl *decl)
|
||||
// If we don't have a type, resolve the expression.
|
||||
if ((init = decl->var.init_expr))
|
||||
{
|
||||
if (init->expr_kind == EXPR_TYPEINFO)
|
||||
{
|
||||
SEMA_ERROR(init, "You can't assign a type to a regular compile time variable like '%s', but it would be allowed if the variable was a compile time type variable. Such a variable needs to have a type-like name, e.g. '$MyType'.", decl->name);
|
||||
goto FAIL;
|
||||
}
|
||||
if (!sema_analyse_expr(context, init)) goto FAIL;
|
||||
// Check it is constant.
|
||||
if (!expr_is_runtime_const(init))
|
||||
|
||||
Reference in New Issue
Block a user