mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Improve error message when providing alias with a typeid expression where a type was expected. #2944
This commit is contained in:
@@ -16,7 +16,8 @@
|
|||||||
- Add `@constinit` to allow old typedef behaviour.
|
- Add `@constinit` to allow old typedef behaviour.
|
||||||
- Include actual element count in the error message when the array initializer size does not match the expected size.
|
- Include actual element count in the error message when the array initializer size does not match the expected size.
|
||||||
- Add `--print-large-functions` for checking which functions likely dominate the compile time.
|
- Add `--print-large-functions` for checking which functions likely dominate the compile time.
|
||||||
|
- Improve error message when providing `alias` with a typeid expression where a type was expected. #2944
|
||||||
|
|
||||||
### Stdlib changes
|
### Stdlib changes
|
||||||
- Summarize sort macros as generic function wrappers to reduce the amount of generated code. #2831
|
- Summarize sort macros as generic function wrappers to reduce the amount of generated code. #2831
|
||||||
- Remove dependency on temp allocator in String.join.
|
- Remove dependency on temp allocator in String.join.
|
||||||
|
|||||||
@@ -2421,8 +2421,12 @@ static inline Decl *parse_alias_type(ParseContext *c, AstId contracts)
|
|||||||
print_error_at(decl->span, "An identifier may not be aliased with type name, it must start with a lower case letter.");
|
print_error_at(decl->span, "An identifier may not be aliased with type name, it must start with a lower case letter.");
|
||||||
}
|
}
|
||||||
return poisoned_decl;
|
return poisoned_decl;
|
||||||
|
case EXPR_TERNARY:
|
||||||
|
case EXPR_CALL:
|
||||||
|
PRINT_ERROR_AT(expr, "Expected a type to alias here, if you are providing a constant typeid-expression, e.g. 'FOO > 32 ??? long : int', then you need to wrap the expression in '$typefrom'");
|
||||||
|
return poisoned_decl;
|
||||||
default:
|
default:
|
||||||
PRINT_ERROR_HERE("Expected a type to alias here.");
|
PRINT_ERROR_AT(expr, "Expected the name of the type to alias here.");
|
||||||
return poisoned_decl;
|
return poisoned_decl;
|
||||||
}
|
}
|
||||||
ASSERT(!tok_is(c, TOKEN_LBRACE));
|
ASSERT(!tok_is(c, TOKEN_LBRACE));
|
||||||
|
|||||||
9
test/test_suite/define/alias_should_typefrom.c3
Normal file
9
test/test_suite/define/alias_should_typefrom.c3
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import std;
|
||||||
|
|
||||||
|
const C = 2;
|
||||||
|
alias BaseType = C < 32 ??? int : long; // #error: Expected a type to alias here, if you are providing a constant typeid-expression
|
||||||
|
|
||||||
|
fn void main()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user