Skip to content

Commit

Permalink
fix(stdlib): Make Bytes.length handle sizes over 2GiB (grain-lang#1123)
Browse files Browse the repository at this point in the history
  • Loading branch information
cician authored Jan 31, 2022
1 parent c4e1911 commit d7386eb
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions stdlib/bytes.gr
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import WasmI64 from "runtime/unsafe/wasmi64"
import WasmF32 from "runtime/unsafe/wasmf32"
import WasmF64 from "runtime/unsafe/wasmf64"
import Conv from "runtime/unsafe/conv"
import {
tagSimpleNumber,
allocateBytes,
allocateString,
} from "runtime/dataStructures"
import { allocateBytes, allocateString } from "runtime/dataStructures"
import Exception from "runtime/exception"
import Int32 from "int32"
import { coerceNumberToWasmI32 } from "runtime/numbers"
Expand Down Expand Up @@ -151,7 +147,7 @@ export let rec toString = (bytes: Bytes) => {
@disableGC
export let rec length = (bytes: Bytes) => {
let b = WasmI32.fromGrain(bytes)
let ret = tagSimpleNumber(getSize(b))
let ret = Conv.wasmI32ToNumber(getSize(b))
Memory.decRef(WasmI32.fromGrain(bytes))
Memory.decRef(WasmI32.fromGrain(length))
ret
Expand Down

0 comments on commit d7386eb

Please sign in to comment.