mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
- Attrdef eval environment lacked rtype, causing error on invalid args #2797
This commit is contained in:
@@ -3668,8 +3668,7 @@ static inline bool sema_analyse_custom_attribute(SemaContext *context, ResolvedA
|
||||
SemaContext eval_context;
|
||||
sema_context_init(&eval_context, attr_decl->unit);
|
||||
eval_context.macro_call_depth = context->macro_call_depth + 1;
|
||||
eval_context.call_env = (CallEnv) { .kind = CALL_ENV_ATTR, .attr_declaration = decl };
|
||||
|
||||
eval_context.call_env = (CallEnv) { .kind = CALL_ENV_ATTR, .attr_declaration = decl, };
|
||||
// We copy the compilation unit.
|
||||
eval_context.compilation_unit = context->unit;
|
||||
|
||||
@@ -3683,6 +3682,7 @@ static inline bool sema_analyse_custom_attribute(SemaContext *context, ResolvedA
|
||||
if (!sema_resolve_type_info(context, type_infoptr(param->var.type_info), RESOLVE_TYPE_DEFAULT)) return false;
|
||||
Type *type = typeget(param->var.type_info);
|
||||
ASSERT_SPAN(decl, type);
|
||||
eval_context.rtype = type;
|
||||
if (!sema_analyse_inferred_expr(context, type, expr, NULL)) goto ERR;
|
||||
if (!cast_implicit(context, expr, type, false)) goto ERR;
|
||||
if (!sema_cast_const(expr))
|
||||
@@ -3693,6 +3693,7 @@ static inline bool sema_analyse_custom_attribute(SemaContext *context, ResolvedA
|
||||
}
|
||||
else
|
||||
{
|
||||
eval_context.rtype = type_void;
|
||||
if (!sema_analyse_ct_expr(context, args[j])) goto ERR;
|
||||
}
|
||||
params[j]->var.init_expr = expr;
|
||||
@@ -3701,6 +3702,7 @@ static inline bool sema_analyse_custom_attribute(SemaContext *context, ResolvedA
|
||||
// (Yes this is messy)
|
||||
sema_add_local(&eval_context, params[j]);
|
||||
}
|
||||
eval_context.rtype = type_void;
|
||||
// Now we've added everything to the evaluation context, so we can (recursively)
|
||||
// apply it to the contained attributes, which in turn may be derived attributes.
|
||||
if (!sema_analyse_attributes_inner(&eval_context, attr_data_ref, decl, attributes, domain, top ? top : attr_decl, erase_decl)) goto ERR;
|
||||
|
||||
Reference in New Issue
Block a user