forked from AbleOS/holey-bytes
Made sure null_check_test
reproduces exact issue.
This commit is contained in:
parent
d4a52b6342
commit
191c49ff1d
|
@ -1059,16 +1059,21 @@ main := fn(): uint {
|
||||||
|
|
||||||
#### null_check_test
|
#### null_check_test
|
||||||
```hb
|
```hb
|
||||||
main := fn(): uint {
|
get_ptr := fn(): ?^uint {
|
||||||
ptr := @as(?^uint, null)
|
|
||||||
value := 0
|
value := 0
|
||||||
ptr = &value
|
return &value
|
||||||
|
|
||||||
if ptr == null {
|
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return *ptr
|
main := fn(): void {
|
||||||
|
ptr := get_ptr()
|
||||||
|
|
||||||
|
if ptr == null {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
loop {
|
||||||
|
*ptr += 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
main:
|
||||||
|
LRA r2, r0, :x
|
||||||
|
LI64 r1, 0d
|
||||||
|
ST r1, r2, 0a, 8h
|
||||||
|
JALA r0, r31, 0a
|
||||||
|
code size: 57
|
||||||
|
ret: 0
|
||||||
|
status: Ok(())
|
|
@ -0,0 +1,6 @@
|
||||||
|
test.hb:15:4: can't prove the value is not 'null', use '@unwrap(<opt>)' if you believe compiler is stupid, or explicitly check for null and handle it ('if <opt> == null { /* handle */ } else { /* use opt */ }')
|
||||||
|
*ptr += 1
|
||||||
|
^
|
||||||
|
test.hb:15:4: can't prove the value is not 'null', use '@unwrap(<opt>)' if you believe compiler is stupid, or explicitly check for null and handle it ('if <opt> == null { /* handle */ } else { /* use opt */ }')
|
||||||
|
*ptr += 1
|
||||||
|
^
|
Loading…
Reference in a new issue