-
Notifications
You must be signed in to change notification settings - Fork 471
Closed
Description
rescript version: 9.1.2 & 10.0.1
See the code in playground
type t = {
data: Js.TypedArray2.Uint8Array.t,
mutable p: int
}
@inline
let readNextByte = decoder => {
decoder.data
->Js.TypedArray2.Uint8Array.unsafe_get({
let p = decoder.p
decoder.p = p + 1
p
})
}
@inline
let readNextTwoByte = decoder => {
decoder->readNextByte->lor(decoder->readNextByte->lsl(8))
}
let decoder = {
data: Js.TypedArray2.Uint8Array.fromLength(10),
p: 0
}
// here may be a bug if use @inline
decoder->readNextTwoByte->ignore
assert (decoder.p === 2)
The decoder.p
should be 2 but 1 in this example. I found this bug in my project and created this example.
Metadata
Metadata
Assignees
Labels
No labels