mirror of
https://github.com/radareorg/quickjs.git
synced 2026-11-07 06:25:57 -10:00
QuickJS reported "cannot read property of null" for computed property lookups (`a[k]` where `a === null`), which is markedly less helpful than "cannot read property 'foo' of null".
39 lines
656 B
JavaScript
39 lines
656 B
JavaScript
import {assert} from "./assert.js"
|
|
|
|
let ex
|
|
try {
|
|
null.x
|
|
} catch (e) {
|
|
ex = e
|
|
}
|
|
assert(ex instanceof TypeError)
|
|
assert(ex.message, "cannot read property 'x' of null")
|
|
ex = undefined
|
|
|
|
try {
|
|
null["x"]
|
|
} catch (e) {
|
|
ex = e
|
|
}
|
|
assert(ex instanceof TypeError)
|
|
assert(ex.message, "cannot read property 'x' of null")
|
|
ex = undefined
|
|
|
|
try {
|
|
undefined.x
|
|
} catch (e) {
|
|
ex = e
|
|
}
|
|
assert(ex instanceof TypeError)
|
|
assert(ex.message, "cannot read property 'x' of undefined")
|
|
ex = undefined
|
|
|
|
try {
|
|
undefined["x"]
|
|
} catch (e) {
|
|
ex = e
|
|
}
|
|
assert(ex instanceof TypeError)
|
|
assert(ex.message, "cannot read property 'x' of undefined")
|
|
ex = undefined
|