$defined(x[0] = val) causes an error instead of returning false when a type does not have []= defined #2454

This commit is contained in:
Christoffer Lerno
2025-09-03 00:08:43 +02:00
parent 14a929588a
commit e25812a071
3 changed files with 28 additions and 14 deletions

View File

@@ -0,0 +1,14 @@
fn int main(String[] args)
{
MyArray a = {{1, 4, 3, 6, 5}};
$assert(!$defined(a[0] = 2));
return 0;
}
struct MyArray
{
int[] val;
}
fn int MyArray.get(self, usz idx) @operator([]) => self.val[idx];
fn usz MyArray.len(self) @operator(len) => self.val.len;