InterfaceConstraint new_ic = {0};
new_ic.expr = (AstTyped *) ast_clone(context.ast_alloc, (AstNode *) ic->expr);
new_ic.expected_type_expr = (AstType *) ast_clone(context.ast_alloc, (AstNode *) ic->expected_type_expr);
+ new_ic.invert_condition = ic->invert_condition;
bh_arr_push(constraint->exprs, new_ic);
}
return cs;
}
- if (cs == Check_Error) {
+ if (cs == Check_Error && !ic->invert_condition) {
+ goto constraint_error;
+ }
+
+ if (cs == Check_Success && ic->invert_condition) {
goto constraint_error;
}
}
TYPE_CHECK(&ic->expr, ic->expected_type) {
- goto constraint_error;
+ if (!ic->invert_condition)
+ goto constraint_error;
}
}
constraint_error:
// HACK HACK HACK
onyx_clear_errors();
-
*constraint->report_status = Constraint_Check_Status_Failed;
return Check_Failed;
}
+ // HACK HACK HACK
+ onyx_clear_errors();
*constraint->report_status = Constraint_Check_Status_Success;
return Check_Complete;
}
if (parser->hit_unexpected_token) return interface;
InterfaceConstraint ic = {0};
+ if (parse_possible_directive(parser, "not")) {
+ ic.invert_condition = 1;
+ }
+
if (consume_token_if_next(parser, '{')) {
ic.expr = parse_expression(parser, 0);