Allow $defined take declarations: $defined(int x = y)

Taking the address of a label would cause a crash. #2430
This commit is contained in:
Christoffer Lerno
2025-08-23 12:00:17 +02:00
parent f36e9fea48
commit e4e499edd2
16 changed files with 109 additions and 56 deletions

View File

@@ -212,8 +212,9 @@ fn Entry*? HashMap.get_entry(&map, Key key)
}
<*
Get the value or update and
@require @assignable_to(#expr, Value)
Get the value or set it to the value
@require $defined(Value val = #expr)
*>
macro Value HashMap.@get_or_set(&map, Key key, Value #expr)
{

View File

@@ -188,8 +188,9 @@ fn LinkedEntry*? LinkedHashMap.get_entry(&map, Key key)
}
<*
Get the value or update and
@require @assignable_to(#expr, Value)
Get the value or set it to the value
@require $defined(Value val = #expr)
*>
macro Value LinkedHashMap.@get_or_set(&map, Key key, Value #expr)
{

View File

@@ -15,8 +15,8 @@ fn usz? Pair.to_format(&self, Formatter* f) @dynamic
<*
@param [&out] a
@param [&out] b
@require @assignable_to(self.first, $typeof(*a)) : "You cannot assign the first value to a"
@require @assignable_to(self.second, $typeof(*b)) : "You cannot assign the second value to b"
@require $defined(*a = self.first) : "You cannot assign the first value to a"
@require $defined(*b = self.second) : "You cannot assign the second value to b"
*>
macro void Pair.unpack(&self, a, b)
{
@@ -49,9 +49,9 @@ fn usz? Triple.to_format(&self, Formatter* f) @dynamic
@param [&out] a
@param [&out] b
@param [&out] c
@require @assignable_to(self.first, $typeof(*a)) : "You cannot assign the first value to a"
@require @assignable_to(self.second, $typeof(*b)) : "You cannot assign the second value to b"
@require @assignable_to(self.third, $typeof(*c)) : "You cannot assign the second value to c"
@require $defined(*a = self.first) : "You cannot assign the first value to a"
@require $defined(*b = self.second) : "You cannot assign the second value to b"
@require $defined(*c = self.third) : "You cannot assign the second value to c"
*>
macro void Triple.unpack(&self, a, b, c)
{