- Ignore const null check on deref in $defined and $sizeof #2633.

This commit is contained in:
Christoffer Lerno
2025-12-10 00:02:24 +01:00
parent e15ee23925
commit 3a8a6aa429
3 changed files with 12 additions and 1 deletions

View File

@@ -12,6 +12,7 @@
- Optional does not play well with bit ops #2618. - Optional does not play well with bit ops #2618.
- `Bytebuffer.grow` was broken #2622. - `Bytebuffer.grow` was broken #2622.
- Hex escapes like `"\x80"` would be incorrectly lowered. #2623 - Hex escapes like `"\x80"` would be incorrectly lowered. #2623
- Ignore const null check on deref in `$defined` and `$sizeof` #2633.
### Stdlib changes ### Stdlib changes
- Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads. - Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads.

View File

@@ -6085,7 +6085,7 @@ TYPE_CALL:
bool sema_expr_rewrite_insert_deref(SemaContext *context, Expr *original) bool sema_expr_rewrite_insert_deref(SemaContext *context, Expr *original)
{ {
if (expr_is_const_pointer(original) && !original->const_expr.ptr) if (expr_is_const_pointer(original) && !original->const_expr.ptr && !context->call_env.in_no_eval)
{ {
RETURN_SEMA_ERROR(original, "This value is known to be null so you cannot dereference it."); RETURN_SEMA_ERROR(original, "This value is known to be null so you cannot dereference it.");
} }

View File

@@ -0,0 +1,10 @@
module test;
import std;
fn int main()
{
int x @if($defined((char*){}.is_digit()));
isz s = $sizeof((char*){}.is_digit());
$typeof((char*){}.is_digit()) t;
return 0;
}