luau-lang / luau

A fast, small, safe, gradually typed embeddable scripting language derived from Lua
https://luau-lang.org
MIT License
3.8k stars 352 forks source link

`LOADK` instruction right after `LOADKX` instead of an auxiliary parameter #1206

Closed amitbashan closed 3 months ago

amitbashan commented 3 months ago

By compiling the following code with optimization level 0:

local a = 123

you will get the bytecode:

0x05, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x03, 0x41,
0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x16, 0x00, 0x01, 0x00, 0x01,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x5E, 0x40, 0x00, 0x01, 0x00,
0x01, 0x18, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00

notice the instruction: 0x41, 0x00, 0x00, 0x00 (0x41 is LOADKX) the next instruction is: 0x05, 0x00, 0x00, 0x00 (0x5 is LOADK) but according to comments in Bytecode.h, there should be an auxiliary parameter right after LOADKX, what am I missing here? is this a bug?

amitbashan commented 3 months ago

Luau version 0.617 installed via brew.