Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/spec.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: "spec"

on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]

jobs:
test:
strategy:
fail-fast: false
matrix:
luaVersion: ["5.1", "5.2", "5.3", "5.4", "luajit", "luajit-openresty"]
luaVersion: ["5.1", "5.2", "5.3", "5.4", "5.5.0", "luajit", "luajit-openresty"]

runs-on: ubuntu-latest

Expand All @@ -19,6 +19,8 @@ jobs:
luaVersion: ${{ matrix.luaVersion }}

- uses: leafo/gh-actions-luarocks@master
with:
luarocksVersion: "3.13.0"

- name: build
run: |
Expand Down
16 changes: 13 additions & 3 deletions moon/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ do
local _obj_0 = require("moonscript.util")
getfenv, setfenv, dump = _obj_0.getfenv, _obj_0.setfenv, _obj_0.dump
end
local p, is_object, type, debug, run_with_scope, bind_methods, defaultbl, extend, copy, mixin, mixin_object, mixin_table, fold
local p, is_object, type, debug, run_with_scope, bind_methods, defaultbl, extend, copy, mixin, mixin_object, mixin_table, fold, len
p = function(o, ...)
print(dump(o))
if select("#", ...) > 0 then
Expand Down Expand Up @@ -149,7 +149,7 @@ mixin_table = function(self, tbl, keys)
end
end
fold = function(items, fn)
local len = #items
len = #items
Copy link

@vendethiel vendethiel Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a bug being introduced

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing in moon/init.moon actually uses this new function, so reusing the same local variable for it and the local here isn't really in conflict (at least, that's why I presume moonscript removed the local from this line; admittedly I just ran moonc over it and then ran busted to make sure I hadn't broken anything else).

if len > 1 then
local accum = fn(items[1], items[2])
for i = 3, len do
Expand All @@ -160,6 +160,15 @@ fold = function(items, fn)
return items[1]
end
end
len = function(tbl)
local largest = 0
for key, val in pairs(tbl) do
if type(key) == "number" and key > largest then
largest = key
end
end
return largest
end
return {
dump = dump,
p = p,
Expand All @@ -174,5 +183,6 @@ return {
mixin = mixin,
mixin_object = mixin_object,
mixin_table = mixin_table,
fold = fold
fold = fold,
len = len
}
11 changes: 10 additions & 1 deletion moon/init.moon
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,16 @@ fold = (items, fn)->
else
items[1]

-- gets largest integer key of tbl
len = (tbl)->
largest = 0
for key, val in pairs tbl
if type(key) == "number" and key > largest
largest = key
largest

{
:dump, :p, :is_object, :type, :debug, :run_with_scope, :bind_methods,
:defaultbl, :extend, :copy, :mixin, :mixin_object, :mixin_table, :fold
:defaultbl, :extend, :copy, :mixin, :mixin_object, :mixin_table, :fold,
:len
}
2 changes: 1 addition & 1 deletion moonscript-dev-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ description = {
dependencies = {
"lua >= 5.1",
"lpeg >= 0.10, ~= 0.11",
"argparse >= 0.7",
-- "argparse >= 0.7",
"luafilesystem >= 1.5"
}

Expand Down
2 changes: 1 addition & 1 deletion moonscript/transform/class.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ super_scope = function(value, t, key)
}
end
return function(self, node, ret, parent_assign)
local name, parent_val, body = unpack(node, 2)
local name, parent_val, body = unpack(node, 2, 4)
if parent_val == "" then
parent_val = nil
end
Expand Down
2 changes: 1 addition & 1 deletion moonscript/transform/class.moon
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ super_scope = (value, t, key) ->
}

(node, ret, parent_assign) =>
name, parent_val, body = unpack node, 2
name, parent_val, body = unpack node, 2, 4
parent_val = nil if parent_val == ""

parent_cls_name = NameProxy "parent"
Expand Down
4 changes: 3 additions & 1 deletion spec/moon_spec.moon
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ describe "moon", ->
Test, Test!, 1, true, nil, "hello"
}

types = [moon.type t for t in *things]
types = {}
for i=1, moon.len things
types[i] = moon.type things[i]
assert.same types, { Test, Test, "number", "boolean", "nil", "string" }

it "should get upvalue", ->
Expand Down