gopher-lua icon indicating copy to clipboard operation
gopher-lua copied to clipboard

Issue #514 : Fix compileRegAssignment cardinality

Open faelys opened this issue 10 months ago • 0 comments

Fixes #514

Changes proposed in this pull request:

  • In compileRegAssignment, use nvars as the assignment cardinality rather than lennames.
  • Remove no-longer-used names argument

I don't really know what I'm doing, I just tried to infer what things were supposed to be doing based on their names. I started with the test case filed in #514 and compared with the behavior of official Lua 5.1. It turned out that luac has extra LOADNIL which reset the registers that weren't correctly reset by gopher-lua, so I poked around compileGenericForStmt and it took me a while to understand why the iteration variable names were fed to compileRegAssignment when its place in the code and the other arguments suggested it should be about initializing internal generator/state/control triplet rather than iteration variables.

I checked that after this change, the opcodes generated by gopher-lua are similar to those from luac, and the whole test suite passes.

faelys avatar Mar 22 '25 14:03 faelys