mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
$typeof(<type>) returns typeinfo, causing errors #2795
This commit is contained in:
@@ -106,6 +106,7 @@
|
||||
- Too deeply nested scopes was a fatal crash and not a regular semantic error. #2796
|
||||
- Recursive definition of tag not detected with nested tag/tagof #2790
|
||||
- Attrdef eval environment lacked rtype, causing error on invalid args #2797
|
||||
- $typeof(<type>) returns typeinfo, causing errors #2795.
|
||||
|
||||
### Stdlib changes
|
||||
- Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads.
|
||||
|
||||
@@ -6900,7 +6900,6 @@ static inline bool sema_expr_analyse_cast(SemaContext *context, Expr *expr, bool
|
||||
{
|
||||
RETURN_SEMA_ERROR(type_info, "Casting to an optional type is not allowed.");
|
||||
}
|
||||
|
||||
if (invalid_cast_ref)
|
||||
{
|
||||
if (!cast_explicit_silent(context, inner, target_type))
|
||||
|
||||
@@ -341,10 +341,12 @@ INLINE bool sema_resolve_typeof(SemaContext *context, TypeInfo *type_info)
|
||||
{
|
||||
case STORAGE_ERROR:
|
||||
return false;
|
||||
case STORAGE_COMPILE_TIME:
|
||||
if (expr_type->type_kind == TYPE_TYPEINFO) expr_type = type_typeid;
|
||||
FALLTHROUGH;
|
||||
case STORAGE_NORMAL:
|
||||
case STORAGE_VOID:
|
||||
case STORAGE_UNKNOWN:
|
||||
case STORAGE_COMPILE_TIME:
|
||||
type_info->type = expr_type;
|
||||
return true;
|
||||
case STORAGE_WILDCARD:
|
||||
|
||||
6
test/test_suite/compile_time/typeof_ct.c3
Normal file
6
test/test_suite/compile_time/typeof_ct.c3
Normal file
@@ -0,0 +1,6 @@
|
||||
fn int main()
|
||||
{
|
||||
int x;
|
||||
double df2 = ($typeof(double))(x); // #error: You cannot cast 'int' to 'typeid'
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user