wrong index for extend

This commit is contained in:
Jakub Doka 2024-11-09 10:28:53 +01:00
parent 65e9f272a8
commit b8032aa840
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
4 changed files with 37 additions and 3 deletions

View file

@ -612,6 +612,39 @@ main := fn(): uint {
### Purely Testing Examples
#### null_check_returning_small_global
```hb
MAGIC := 127
get := fn(file: ^u8): ?uint {
if *file == MAGIC {
return MAGIC
} else {
return null
}
}
some_file := [u8].(127, 255, 255, 255, 255, 255)
foo := fn(): ?uint {
gotten := get(&some_file[0])
if gotten == null {
return null
} else if gotten == 4 {
return 2
} else if gotten == MAGIC {
return 0
}
return null
}
main := fn(): uint {
f := foo()
if f == null return 100
return f
}
```
#### null_check_in_the_loop
```hb
A := struct {

View file

@ -4640,6 +4640,7 @@ mod tests {
fb_driver;
// Purely Testing Examples;
null_check_returning_small_global;
null_check_in_the_loop;
stack_provenance;
advanced_floating_point_arithmetic;

View file

@ -264,8 +264,8 @@ impl HbvmBackend {
} else if let Some(against) = op.cmp_against() {
let op_ty = fuc.nodes[rh].ty;
self.emit(extend(fuc.nodes[lh].ty, fuc.nodes[lh].ty.extend(), 0, 0));
self.emit(extend(fuc.nodes[rh].ty, fuc.nodes[rh].ty.extend(), 1, 1));
self.emit(extend(fuc.nodes[lh].ty, fuc.nodes[lh].ty.extend(), 1, 1));
self.emit(extend(fuc.nodes[rh].ty, fuc.nodes[rh].ty.extend(), 2, 2));
let &[dst, lhs, rhs] = allocs else { unreachable!() };
if op_ty.is_float() && matches!(op, TokenKind::Le | TokenKind::Ge) {