Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Shopify/go-lua
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: speedata/go-lua
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 20 commits
  • 81 files changed
  • 1 contributor

Commits on Dec 26, 2025

  1. Upgrade to Lua 5.3

    - Native 64-bit integer support (int64)
      - Bitwise operators: &, |, ~, <<, >>
      - Integer division: //
      - UTF-8 library
      - String packing (string.pack/unpack)
      - Math extensions (math.tointeger, math.type, etc.)
      - Fixed for-loop integer semantics
      - Fixed vararg stack overflow
      - 10/11 official Lua 5.3 tests pass"
    pgundlach committed Dec 26, 2025
    Configuration menu
    Copy the full SHA
    6fbad5a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0a75b29 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8bc2f1e View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    b015d5d View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    f940d67 View commit details
    Browse the repository at this point in the history
  6. Fix sort.lua test

    - error() now preserves any value as error object (not just strings)
      In Lua 5.3, error(value) can be called with tables, nil, etc.
      The value stays on the stack and is returned by pcall.
    
    - table.sort: add "array too big" check for __len > INT_MAX
      Prevents hang when metatable returns huge length values.
    
    - table.move: add "too many elements to move" validation
      Matches Lua 5.3 reference implementation bounds checking.
    pgundlach committed Dec 26, 2025
    Configuration menu
    Copy the full SHA
    afdd10d View commit details
    Browse the repository at this point in the history
  7. Implement debug.getinfo Lua wrapper

    Add debug.getinfo function that returns introspection data about
    functions and stack frames. Supports all standard options:
    - 'S': source, short_src, linedefined, lastlinedefined, what
    - 'l': currentline
    - 'u': nups, nparams, isvararg
    - 'n': name, namewhat
    - 't': istailcall
    - 'f': func (the function itself)
    - 'L': activelines table
    
    The core Info() Go function already existed - this adds the Lua-facing
    wrapper that builds the result table.
    
    calls.lua and constructs.lua now progress further but fail on other
    issues (load reader function, operator precedence).
    pgundlach committed Dec 26, 2025
    Configuration menu
    Copy the full SHA
    345416d View commit details
    Browse the repository at this point in the history
  8. Cache ipairs iterator function

    In Lua 5.3, ipairs{} must return the same iterator function each time
    (ipairs{} == ipairs{}). Previously, each call created a new Go function.
    
    Now the iterator is cached in the registry on first use and reused for
    all subsequent ipairs calls. Uses a unique pointer key to avoid
    collisions with user data.
    
    This enables the nextvar.lua test to progress further (now fails on
    a different issue: "invalid key to next").
    pgundlach committed Dec 26, 2025
    Configuration menu
    Copy the full SHA
    a3df8bf View commit details
    Browse the repository at this point in the history
  9. string-to-integer coercion for bitwise operations

    Lua 5.3 requires strings to be coerced to integers for bitwise
    operations. This commit implements that behavior:
    
    - Add toIntegerString() method in types.go for string coercion
    - Change coerceToIntegers to State method using toIntegerString
    - Update all bitwise op call sites in vm.go (BAND, BOR, BXOR,
      SHL, SHR, BNOT)
    - Fix functionName() to use savedPC-1 for correct call instruction
    - Enable bitwise and constructs tests in vm_test.go
    
    The bitwise and constructs Lua 5.3 tests now pass.
    pgundlach committed Dec 26, 2025
    Configuration menu
    Copy the full SHA
    2233fa4 View commit details
    Browse the repository at this point in the history
  10. Fix math.lua test suite

    Scanner:
    - Add readHexFraction for fractional hex digits without overflow
    - Track overflow digits as exponent adjustment in readHexNumber
    
    Types:
    - Add 4th return value (ok) to parseNumberEx for validation
    - Fix tonumber('0x') returning 0 instead of nil
    
    Math library:
    - math.abs: preserve integer type, overflow wrapping for minint
    - math.atan: support optional second argument (atan2)
    - math.tointeger: range check before int64 conversion
    - math.fmod: preserve integer type, "zero" error for div by 0
    - math.max/min: preserve integer type, "value expected" error
    - math.random: return integers, proper range handling up to 2^63
    
    Debug:
    - bitwiseError includes field/upvalue names from debug info
    pgundlach committed Dec 26, 2025
    Configuration menu
    Copy the full SHA
    dc1fe7b View commit details
    Browse the repository at this point in the history
  11. Update Readme

    pgundlach committed Dec 26, 2025
    Configuration menu
    Copy the full SHA
    6f18b28 View commit details
    Browse the repository at this point in the history
  12. Fix closure.lua test hang

    The test had a loop waiting for weak references to be GC'd,
    but go-lua doesn't support weak refs (__mode metatables).
    
    Added _noweakref flag to skip the weak reference loop.
    This enables the closure test in the test suite.
    pgundlach committed Dec 26, 2025
    Configuration menu
    Copy the full SHA
    20ae991 View commit details
    Browse the repository at this point in the history
  13. go fmt and minor cleanups

    - Format all source files with go fmt
    - Fix undump.go shift warning (instruction is always 32-bit)
    - Remove dead code in io.go (err was always nil)
    - Update TestIntegerValues for strict integerValues behavior
    pgundlach committed Dec 26, 2025
    Configuration menu
    Copy the full SHA
    46164b2 View commit details
    Browse the repository at this point in the history
  14. Fix next() err when deleting keys during iteration

    The next() function would throw "invalid key to 'next'" when the
    current key was deleted from the hash table during iteration.
    
    Fix: Check if the key matches our position marker before checking
    if it was deleted. This allows iteration to continue correctly
    even when keys are removed mid-iteration.
    pgundlach committed Dec 26, 2025
    Configuration menu
    Copy the full SHA
    10df49a View commit details
    Browse the repository at this point in the history

Commits on Dec 27, 2025

  1. Add table library metamethod support

    table.insert, table.remove, table.sort now respect __index/__newindex
    metamethods, allowing them to work with proxy tables.
    
    Changes:
    - table.insert: Use Table/SetTable instead of RawGetInt/RawSetInt
    - table.remove: Use Table/SetTable for element shifting
    - table.sort: Update sortHelper.Swap/Less to use metamethods
    - table.concat: Use Table for reading elements
    - table.unpack: Use Table for reading elements, fix integer overflow
      bug when iterating near maxInt
    
    Also adds comprehensive tests for metamethod support.
    pgundlach committed Dec 27, 2025
    Configuration menu
    Copy the full SHA
    2d3c5df View commit details
    Browse the repository at this point in the history
  2. Fix EXTRAARG handling for large tables

    EncodeConstant was using opLoadConstant instead of opLoadConstantEx
    when constant index exceeded maxArgBx (262143). The VM expects
    opLoadConstantEx to read the index from the following EXTRAARG
    instruction.
    
    Adds TestLargeTableExtraArg to verify tables with >262143 elements.
    pgundlach committed Dec 27, 2025
    Configuration menu
    Copy the full SHA
    184fdc7 View commit details
    Browse the repository at this point in the history
  3. Implement file:read() with all format specifiers

    Add full f:read() support for file handles:
    - read("l")/read("*l"): line without EOL (default)
    - read("L")/read("*L"): line with EOL
    - read("n")/read("*n"): number (integer, float, hex)
    - read("a")/read("*a"): entire file
    - read(n): n bytes
    - read(0): EOF test
    
    Also fixes write() to preserve string content exactly (was
    incorrectly converting numeric-looking strings through number
    conversion, losing newlines like "123\n" -> "123").
    pgundlach committed Dec 27, 2025
    Configuration menu
    Copy the full SHA
    f7627dd View commit details
    Browse the repository at this point in the history
  4. Implement io.popen for process I/O

    Add io.popen(command, mode) support:
    - Read mode ("r"): capture command stdout
    - Write mode ("w"): pipe to command stdin
    - close() returns true on success, or nil/error/exitcode on failure
    
    Uses os.Pipe() to get real file descriptors compatible with
    existing stream infrastructure.
    pgundlach committed Dec 27, 2025
    Configuration menu
    Copy the full SHA
    1790b92 View commit details
    Browse the repository at this point in the history
  5. Replace deprecated io/ioutil with io and os

    - ioutil.ReadAll → io.ReadAll
    - ioutil.ReadFile → os.ReadFile
    - ioutil.TempFile → os.CreateTemp
    
    Also fix popen to use /bin/sh and ensure PATH includes
    standard locations for subprocess commands.
    pgundlach committed Dec 27, 2025
    Configuration menu
    Copy the full SHA
    b81c2b8 View commit details
    Browse the repository at this point in the history
  6. Add Windows support for io.popen

    Use cmd.exe /c on Windows, /bin/sh -c on Unix.
    PATH extension only needed on Unix due to sandbox environments.
    pgundlach committed Dec 27, 2025
    Configuration menu
    Copy the full SHA
    1625738 View commit details
    Browse the repository at this point in the history
Loading