hhvm icon indicating copy to clipboard operation
hhvm copied to clipboard

Missing optional `$offset` argument from `\unpack()`

Open lexidor opened this issue 4 years ago • 0 comments

Describe the bug PHP 7.1.0 added an $offset parameter to \unpack().

Standalone code, or other way to reproduce the problem

\unpack('Q', $bytes, 16);

Expected behavior

\unpack() should parse a value starting on the 17th byte of $bytes.

Actual behavior

Typing[4105] Too many arguments (expected 2 but got 3) [1]
-> Definition is here [2]

file.hack:17:12
[1] 17 |     $int = \unpack('Q', $bytes, 16)[1];

stdlib/builtins_misc.hhi:53:10
    52 | <<__PHPStdLib>>
[2] 53 | function unpack(string $format, string $data)[];

1 error found.

'RuntimeException' with message 'unpack() expects exactly 2 parameters, 3 given'

Environment

  • Operating system

Ubuntu 20.04

  • Installation method

apt-get with dl.hhvm.com repository

  • HHVM Version
HipHop VM 4.104.0 (rel)
Compiler: 1617657983_425656103
Repo schema: d1ae8e21bf3419a65f12a010527485564e719d07
hackc-19fbbad2737663654aca6bc309c53be65c76d7f7-4.104.0

Additional context Slicing the string in Hack is possible, but less performant.

lexidor avatar Apr 11 '21 01:04 lexidor