ceifa / wasmoon

A real lua 5.4 VM with JS bindings made with webassembly
MIT License
496 stars 32 forks source link

Lua goto broken when going from 1.12.1 to 1.14.0 #57

Closed Drumsin closed 2 years ago

Drumsin commented 2 years ago

After updating wasmoon, experiencing error with goto statements. Line -14346: ')' expected near

Line 14346 is the goto statement ::tryAgain:: below.

function placeRandomNumberOfTilesInRing(rowCoord, colCoord, numberOfTilesToDraw, chosenTerrain, ringRadius, ringWidth, terrainTypes, terrainLayoutResult)
    count = 0
    neighbors = GetAllSquaresOfTypeInRingAroundSquare(rowCoord, colCoord, ringRadius, ringWidth, terrainTypes, terrainLayoutResult)
    print('placeRandomNumberOfTilesInRing: '..#neighbors..' neighbors found')

    if (#neighbors < 1) then
        print('placeRandomNumberOfTilesInRing: No neighbor tiles found. Check selected terrainTypes')
        return
    end

    if (numberOfTilesToDraw > #neighbors) then
        print('placeRandomNumberOfTilesInRing: number of tiles to draw is less than found neighbors. Setting numberOfTilesToDraw to '..#neighbors)
        numberOfTilesToDraw = #neighbors
    end

    ::tryAgain::
    print('placeRandomNumberOfTilesInRing: making pass to place random terrain')
    for k, v in ipairs(neighbors) do

        --start again here
        chosenIndex = GetRandomIndex(neighbors)

        if (count < numberOfTilesToDraw and terrainLayoutResult[neighbors[chosenIndex][1]][neighbors[chosenIndex][2]].terrainType ~= chosenTerrain) then
            terrainLayoutResult[neighbors[chosenIndex][1]][neighbors[chosenIndex][2]].terrainType = chosenTerrain
            table.remove(neighbors, chosenIndex)
            count = count + 1
        end

    end

    if (count < numberOfTilesToDraw) then
        goto tryAgain
    end    

end
Drumsin commented 2 years ago

Closing for now. Need to investigate further. As other code that is not posted may be the offender.