- @is_const is deprecated in favour of directly using $defined.

- `@is_lvalue(#value)` is deprecated in favour of directly using `$defined`.
This commit is contained in:
Christoffer Lerno
2025-08-27 18:21:55 +02:00
parent 3c6e6f1965
commit 7312c10b9e
6 changed files with 10 additions and 9 deletions

View File

@@ -69,7 +69,7 @@ alias VoidFn = fn void();
macro scope. macro scope.
@param #variable : `the variable to store and restore` @param #variable : `the variable to store and restore`
@require values::@is_lvalue(#variable) @require $defined(#variable = #variable) : `Expected an actual variable`
*> *>
macro void @scope(#variable; @body) @builtin macro void @scope(#variable; @body) @builtin
{ {

View File

@@ -16,12 +16,11 @@ macro bool @is_promotable_to_floatlike(#value) @const => types::is_promotable_to
macro bool @is_promotable_to_float(#value) @const => types::is_promotable_to_float($typeof(#value)); macro bool @is_promotable_to_float(#value) @const => types::is_promotable_to_float($typeof(#value));
macro bool @is_vector(#value) @const => types::is_vector($typeof(#value)); macro bool @is_vector(#value) @const => types::is_vector($typeof(#value));
macro bool @is_same_vector_type(#value1, #value2) @const => types::is_same_vector_type($typeof(#value1), $typeof(#value2)); macro bool @is_same_vector_type(#value1, #value2) @const => types::is_same_vector_type($typeof(#value1), $typeof(#value2));
macro bool @assign_to(#value1, #value2) @const @deprecated("use '$define(#value1 = #value2)'") => @assignable_to(#value1, $typeof(#value2)); macro bool @assign_to(#value1, #value2) @const @deprecated("use '$defined(#value1 = #value2)'") => @assignable_to(#value1, $typeof(#value2));
macro bool @is_lvalue(#value) => $defined(#value = #value); macro bool @is_lvalue(#value) @deprecated("use '$defined(#value = #value)'")=> $defined(#value = #value);
macro bool @is_const(#foo) @const @builtin macro bool @is_const(#foo) @const @builtin @deprecated("use '$defined(var $v = expr)'")
{ {
var $v; return $defined(var $v = #foo);
return $defined($v = #foo);
} }
macro promote_int(x) macro promote_int(x)

View File

@@ -28,6 +28,8 @@
- If the `os-arch` linked library doesn't exist, try with `os` for c3l libs. - If the `os-arch` linked library doesn't exist, try with `os` for c3l libs.
- A file with an inferred module may not contain additional other modules. - A file with an inferred module may not contain additional other modules.
- Update error message for missing body after if/for/etc #2289. - Update error message for missing body after if/for/etc #2289.
- `@is_const` is deprecated in favour of directly using `$defined`.
- `@is_lvalue(#value)` is deprecated in favour of directly using `$defined`.
### Fixes ### Fixes
- List.remove_at would incorrectly trigger ASAN. - List.remove_at would incorrectly trigger ASAN.
@@ -193,7 +195,7 @@
- Added Ed25519. - Added Ed25519.
- Added string::bformat. - Added string::bformat.
- Virtual memory library. - Virtual memory library.
- New virtual emory arena allocator. - New virtual memory arena allocator.
- Added `WString.len`. - Added `WString.len`.
- Added `@addr` macro. - Added `@addr` macro.
- Add `ConditionVariable.wait_until` and `ConditionVariable.wait_for` - Add `ConditionVariable.wait_until` and `ConditionVariable.wait_for`

View File

@@ -1210,7 +1210,6 @@ static Expr *parse_ct_is_const(ParseContext *c, Expr *left, SourceSpan lhs_start
ASSIGN_EXPR_OR_RET(checks->inner_expr, parse_expr(c), poisoned_expr); ASSIGN_EXPR_OR_RET(checks->inner_expr, parse_expr(c), poisoned_expr);
CONSUME_OR_RET(TOKEN_RPAREN, poisoned_expr); CONSUME_OR_RET(TOKEN_RPAREN, poisoned_expr);
RANGE_EXTEND_PREV(checks); RANGE_EXTEND_PREV(checks);
SEMA_DEPRECATED(checks, "The $is_const macro is deprecated. Use @is_const(...) instead.");
return checks; return checks;
} }

View File

@@ -10268,6 +10268,7 @@ ERROR:
static inline bool sema_expr_analyse_ct_is_const(SemaContext *context, Expr *expr) static inline bool sema_expr_analyse_ct_is_const(SemaContext *context, Expr *expr)
{ {
SEMA_DEPRECATED(expr, "$is_const is deprecated, use '$defined(var $e = expr)' instead.");
ASSERT_SPAN(expr, expr->resolve_status == RESOLVE_RUNNING); ASSERT_SPAN(expr, expr->resolve_status == RESOLVE_RUNNING);
Expr *inner = expr->inner_expr; Expr *inner = expr->inner_expr;
if (!sema_analyse_expr(context, inner)) return false; if (!sema_analyse_expr(context, inner)) return false;

View File

@@ -18,7 +18,7 @@ fn void main()
} }
<* <*
@require values::@is_lvalue(#s) @require $defined(#s = #s)
*> *>
macro int @read_int(String #s) macro int @read_int(String #s)
{ {