instance_id stringlengths 51 65 | patch stringlengths 288 6.98k | FAIL_TO_PASS listlengths 1 26 | PASS_TO_PASS listlengths 2 27 | image_name stringclasses 1
value | repo stringclasses 1
value | problem_statement stringlengths 626 1.97k |
|---|---|---|---|---|---|---|
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__0ze9uo2o | diff --git a/lua/pl/utils.lua b/lua/pl/utils.lua
index ca2a022..ee1c800 100644
--- a/lua/pl/utils.lua
+++ b/lua/pl/utils.lua
@@ -488,14 +488,14 @@ end
function utils.on_error (mode)
mode = tostring(mode)
if ({['default'] = 1, ['quit'] = 2, ['error'] = 3})[mode] then
- err_mode = mode
- else
- --... | [
"tests/test-data2.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.l... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | ## `utils.on_error()` fails when setting valid error modes
### Description
I'm encountering an issue with the `utils.on_error()` function when trying to set the error mode. When I call `utils.on_error('quit')` (or any other valid mode like `'default'` or `'error'`), it raises an error instead of setting the mode.
He... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__3qgsojbk | diff --git a/lua/pl/input.lua b/lua/pl/input.lua
index f81de87..0ba996a 100644
--- a/lua/pl/input.lua
+++ b/lua/pl/input.lua
@@ -56,6 +56,8 @@ local alltokens = input.alltokens
-- @return a getter function
function input.create_getter(f)
if f then
+ return io.read
+ else
if type(f) == 'string'... | [
"tests/test-seq.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the code logic in `input.create_getter` has been incorrectly restructured, causing it to always return `io.read` when `f` is truthy, regardless of what type `f` actually is.
---
`input.create_getter` returns `io.read` for all non-nil inputs
I'm experiencing an iss... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__4peh2qyi | diff --git a/lua/pl/utils.lua b/lua/pl/utils.lua
index ca2a022..5001f3d 100644
--- a/lua/pl/utils.lua
+++ b/lua/pl/utils.lua
@@ -781,6 +781,8 @@ end
local function _string_lambda(f)
if f:find '^|' or f:find '_' then
+ return raise 'not a string lambda'
+ else
local args,body = f:match '|([^|]... | [
"tests/test-__vector.lua",
"tests/test-list.lua",
"tests/test-seq.lua",
"tests/test-tablex.lua"
] | [
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list2.lua... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the logic for detecting string lambdas has been inverted, causing valid string lambda expressions to be rejected with "not a string lambda" errors.
---
String lambda detection broken - rejects valid lambda expressions
I'm getting errors when trying to use string l... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__5kkisuyq | diff --git a/lua/pl/path.lua b/lua/pl/path.lua
index 011b979..5ecdad9 100644
--- a/lua/pl/path.lua
+++ b/lua/pl/path.lua
@@ -286,9 +286,9 @@ function path.splitext(P)
ch = at(P,i)
end
if i == 0 then
- return P,''
- else
return sub(P,1,i-1),sub(P,i)
+ else
+ return P,''
... | [
"tests/test-path.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | **Describe the bug**
The `path.splitext()` function is returning incorrect values when a file has no extension. It appears to be returning the full path as the extension part and an empty string as the base part, when it should be doing the opposite.
**To Reproduce**
```lua
local path = require('pl.path')
-- Test w... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__7izyw1vy | diff --git a/lua/pl/lapp.lua b/lua/pl/lapp.lua
index 3bd752d..f40d8c8 100644
--- a/lua/pl/lapp.lua
+++ b/lua/pl/lapp.lua
@@ -196,13 +196,13 @@ function lapp.process_options_string(str,args)
local function set_result(ps,parm,val)
parm = type(parm) == "string" and parm:gsub("%W", "_") or parm -- so foo-bar ... | [
"tests/test-lapp.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lexer.lua",
"tests/test-list.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | **Describe the bug**
When using lapp (Lua command-line argument parser) with short flag options, the program crashes with an error "attempt to index a nil value (field 'long')". This appears to happen when processing command-line flags that use the short form (e.g., `-v`) without a corresponding long form.
**To Repro... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__9k1bkjle | diff --git a/lua/pl/luabalanced.lua b/lua/pl/luabalanced.lua
index a1f7dc6..4d0733c 100644
--- a/lua/pl/luabalanced.lua
+++ b/lua/pl/luabalanced.lua
@@ -192,7 +192,7 @@ local function match_namelist(s, pos)
while 1 do
local c = #list == 0 and '^' or '^%s*,%s*'
local item, post = s:match(c .. '([%a_][%w_]*)... | [
"tests/test-comprehension.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that a change to the `match_namelist` function in `luabalanced.lua` is causing a "syntax error: zero variables" in the comprehension module. Let me create a realistic GitHub issue mimicking the demonstration style.
---
## Comprehension syntax error with empty variable l... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__aotjqdso | diff --git a/lua/pl/config.lua b/lua/pl/config.lua
index ebd531c..baf003e 100644
--- a/lua/pl/config.lua
+++ b/lua/pl/config.lua
@@ -130,7 +130,7 @@ function config.read(file,cnfg)
local function check_cnfg (var,def)
local val = cnfg[var]
- if val == nil then return def else return val end
+ ... | [
"tests/test-config.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lu... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | [Bug]: config.read() returns nil instead of default value when config variable is not set
### Bug summary
When using `config.read()` to read configuration files, if a configuration variable is not set in the config table, the function returns `nil` instead of the provided default value. This breaks code that relies o... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__b9lhuw06 | diff --git a/lua/pl/luabalanced.lua b/lua/pl/luabalanced.lua
index a1f7dc6..6ee0a05 100644
--- a/lua/pl/luabalanced.lua
+++ b/lua/pl/luabalanced.lua
@@ -137,8 +137,7 @@ local function match_expression(s, pos)
while pos do
local c = s:sub(pos,pos)
if c == '"' or c == "'" or c == '[' and s:find('^[=%[]', pos... | [
"tests/test-comprehension.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the code change in `luabalanced.lua` has broken string parsing in expressions, causing a syntax error in the comprehension module. Let me create a realistic GitHub issue mimicking the demonstration style:
---
## luabalanced.match_expression fails to parse string li... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__bgaemf26 | diff --git a/lua/pl/sip.lua b/lua/pl/sip.lua
index 5d1f2aa..9673483 100644
--- a/lua/pl/sip.lua
+++ b/lua/pl/sip.lua
@@ -147,9 +147,9 @@ function sip.create_pattern (spec,options)
-- this kludge is necessary because %q generates two matches, and
-- we want to ignore the first. Not a problem for named ... | [
"tests/test-lapp.lua",
"tests/test-sip.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lexer.lua",
"tests/test-list.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the changes to `lua/pl/sip.lua` have introduced issues with the `sip.create_pattern` function. The test output shows errors like "attempt to call a nil value" in tests that use this module.
Let me create a realistic GitHub issue mimicking the demonstration style:
-... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__e22ymkgv | diff --git a/lua/pl/input.lua b/lua/pl/input.lua
index f81de87..ec891d8 100644
--- a/lua/pl/input.lua
+++ b/lua/pl/input.lua
@@ -34,13 +34,13 @@ function input.alltokens (getter,pattern,fn)
while line do -- repeat while there are lines
local s, e = strfind(line, pattern, pos)
if s... | [
"tests/test-seq.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch, I can see that the logic in the `alltokens` function has been inverted - the code that should execute when a token is found is now executing when no token is found, and vice versa. This will cause the function to skip over tokens instead of returning them.
Let me create a realistic GitHub issue m... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__f8zw7rgg | diff --git a/lua/pl/Set.lua b/lua/pl/Set.lua
index ce428f0..e7f1254 100644
--- a/lua/pl/Set.lua
+++ b/lua/pl/Set.lua
@@ -49,9 +49,9 @@ function Set:_init (t)
t = t or {}
local mt = getmetatable(t)
if mt == Set or mt == Map then
- for k in pairs(t) do self[k] = true end
- else
for _,v i... | [
"tests/test-map.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Set initialization from Map/Set objects broken
When initializing a Set from another Set or Map object, the values are not being correctly extracted. The Set constructor should use `ipairs` to iterate over Set/Map objects to get their values, but currently it's using `pairs` which gets the keys instead.
For example:
... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__fdvqddxc | diff --git a/lua/pl/url.lua b/lua/pl/url.lua
index 8c7cfeb..200ab61 100644
--- a/lua/pl/url.lua
+++ b/lua/pl/url.lua
@@ -20,10 +20,10 @@ function url.quote(s, quote_plus)
s = s:gsub("\n", "\r\n")
s = s:gsub("([^A-Za-z0-9 %-_%./])", quote_char)
if quote_plus then
+ s = s:gsub(" ", "%%20")
+ else... | [
"tests/test-url.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the `url.quote` function's behavior has been changed, causing URL encoding to work incorrectly. The test output shows:
```
test-url.lua:8: assertion failed
got: "+-_.%2F"
needed: "%20-_./"
```
This indicates that when `quote_plus` is `false`, spaces are being encod... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__fovbcm2e | diff --git a/lua/pl/Date.lua b/lua/pl/Date.lua
index 039dbaf..62eecf1 100644
--- a/lua/pl/Date.lua
+++ b/lua/pl/Date.lua
@@ -424,9 +424,9 @@ function Date.Format:_init(fmt)
append(patt,OPENP..p..CLOSEP)
append(vars,ch)
if ch == 'y' then
- append(outf,cnt==2 and '%y'... | [
"tests/test-date.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Date format parsing broken for year patterns
### Bug description
Date format parsing appears to be broken when using year format patterns. The logic for handling year format codes seems to be inverted, causing incorrect format string generation.
### Command used
```lua
local Date = require 'pl.Date'
-- Try parsing... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__gs88ua8c | diff --git a/lua/pl/lexer.lua b/lua/pl/lexer.lua
index 9219716..3937cb5 100644
--- a/lua/pl/lexer.lua
+++ b/lua/pl/lexer.lua
@@ -181,33 +181,14 @@ function lexer.scan(s,matches,filter,options)
if tlist then -- returning the inserted token list
local cur = tlist[tlist_i]
if cur then
+ ... | [
"tests/test-lexer.lua",
"tests/test-pretty.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-list.l... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the code reorganization in `lexer.lua` has introduced a bug. The patch moves code blocks around, specifically swapping the order of handling different token types. The test output shows an error: `bad argument #2 to 'strfind' (string expected, got nil)` at line 249.
... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__gv0dzjeu | diff --git a/lua/pl/xml.lua b/lua/pl/xml.lua
index 3f49c49..6a9ea96 100644
--- a/lua/pl/xml.lua
+++ b/lua/pl/xml.lua
@@ -164,10 +164,10 @@ function _M.elem(tag, items)
elseif type(items) == 'table' then
for k,v in pairs(items) do
if is_text(k) then
+ s[k] = v
+ else
s.attr[k] = v
... | [
"tests/test-xml.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the change in `xml.lua` swapped the logic for handling text vs. attribute items in the `elem` function. The test failure shows "size 2 ~= size 0 for tag children", indicating that child elements are not being added correctly.
Let me write a GitHub issue mimicking th... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__i0j3yz0b | diff --git a/lua/pl/template.lua b/lua/pl/template.lua
index c10a1f6..3e11e46 100644
--- a/lua/pl/template.lua
+++ b/lua/pl/template.lua
@@ -48,9 +48,9 @@ local function parseDollarParen(pieces, chunk, exec_pat, newline)
end
local remainder, newlines_removed
if newline then
- remainder, newlines_r... | [
"tests/test-template.lua",
"tests/test-template2.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Template rendering removes newlines incorrectly when using `$(...)` syntax
I'm experiencing an issue with the template module where newlines are being removed when they shouldn't be. When using the `$(...)` syntax in templates, the output is missing expected newlines.
Here's a simple example to reproduce:
```lua
loc... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__imjrpnj7 | diff --git a/lua/pl/xml.lua b/lua/pl/xml.lua
index 3f49c49..9441625 100644
--- a/lua/pl/xml.lua
+++ b/lua/pl/xml.lua
@@ -1038,9 +1038,9 @@ do
local numkey,val = has_one_element(tbl)
if numkey == 0 then tbl = val end
if key then
- res[key] = tbl
- ... | [
"tests/test-xml.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the code change in `lua/pl/xml.lua` has introduced a bug. The patch swaps the logic in an if-else block, causing the wrong assignment to occur. The test output shows an error: `/testbed/lua/pl/xml.lua:1043: table index is nil`.
Let me create a realistic GitHub issue... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__jl6hx4dx | diff --git a/lua/pl/func.lua b/lua/pl/func.lua
index 4fdfb46..7831466 100644
--- a/lua/pl/func.lua
+++ b/lua/pl/func.lua
@@ -320,8 +320,8 @@ end
-- @return the function
function func.I(e)
if rawget(e,'__PE_function') then
- return e.__PE_function
- else return func.instantiate(e)
+ return func.... | [
"tests/test-data.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | **Describe the bug**
When using `func.I()` with a placeholder expression that has the `__PE_function` field set, the function returns `nil` instead of the expected function.
**To Reproduce**
```lua
local func = require 'pl.func'
-- Create a placeholder expression with __PE_function set
local pe = {}
pe.__PE_functio... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__kenmvrve | diff --git a/lua/pl/OrderedMap.lua b/lua/pl/OrderedMap.lua
index 379c44f..41aaace 100644
--- a/lua/pl/OrderedMap.lua
+++ b/lua/pl/OrderedMap.lua
@@ -42,21 +42,21 @@ local assert_arg,raise = utils.assert_arg,utils.raise
function OrderedMap:update (t)
assert_arg(1,t,'table')
if OrderedMap:class_of(t) then
- ... | [
"tests/test-orderedmap.lua",
"tests/test-template2.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the `OrderedMap:update` method has a logic error where the conditions for handling different types of input tables have been swapped. This causes the wrong iteration method to be used for different table types.
Let me create a realistic GitHub issue mimicking the de... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__ljj1rdn9 | diff --git a/lua/pl/seq.lua b/lua/pl/seq.lua
index 1c08d20..6998ab0 100644
--- a/lua/pl/seq.lua
+++ b/lua/pl/seq.lua
@@ -101,8 +101,8 @@ function seq.range(start,finish)
local i = start - 1
return function()
i = i + 1
- if i > finish then return nil
- else return i end
+ if i > finish then r... | [
"tests/test-seq.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | **seq.range() returns values in reverse order**
I'm using Penlight's `seq.range()` function and it seems to be returning values backwards - it returns values when it should stop, and stops when it should return values.
**To Reproduce**
```lua
local seq = require 'pl.seq'
local List = require 'pl.List'
-- Try to get... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__ltb782ev | diff --git a/lua/pl/xml.lua b/lua/pl/xml.lua
index 3f49c49..328cfbd 100644
--- a/lua/pl/xml.lua
+++ b/lua/pl/xml.lua
@@ -1065,15 +1065,7 @@ do
-- attribute string matching is straight equality, except if the pattern is a $ capture,
-- which always succeeds.
if is_text(d) then
- if ... | [
"tests/test-xml.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | XML matching fails when comparing text nodes against element nodes
#### Description
The XML matching logic in `lua/pl/xml.lua` appears to have incorrect behavior when matching text nodes against element nodes. When attempting to match XML patterns, the function incorrectly handles the case where one node is a text no... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__lvqiqzq9 | diff --git a/lua/pl/comprehension.lua b/lua/pl/comprehension.lua
index 39be7c5..462438a 100644
--- a/lua/pl/comprehension.lua
+++ b/lua/pl/comprehension.lua
@@ -178,19 +178,19 @@ local function code_comprehension(
end
for i=#invarlists,1,-1 do
if not fortypes[i] then
- local arrayname = '__in' .. i
- ... | [
"tests/test-comprehension.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the code in `comprehension.lua` has had its conditional logic inverted - the `if not fortypes[i]` and `else` blocks have been swapped. This is causing an error where `table_concat` is being called with a boolean value instead of a table.
Here's a realistic GitHub is... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__n7duteg2 | diff --git a/lua/pl/tablex.lua b/lua/pl/tablex.lua
index 3606912..605e25f 100644
--- a/lua/pl/tablex.lua
+++ b/lua/pl/tablex.lua
@@ -835,11 +835,11 @@ function tablex.set (t,val,i1,i2)
i1,i2 = i1 or 1,i2 or #t
if types.is_callable(val) then
for i = i1,i2 do
- t[i] = val(i)
+ t[i... | [
"tests/test-tablex.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the `tablex.set` function has had its logic for callable vs non-callable values swapped, causing an error when trying to call a number value.
<issue>
tablex.set() swaps callable and non-callable value handling
When using `tablex.set()` with a non-callable value (l... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__ptuhstvy | diff --git a/lua/pl/seq.lua b/lua/pl/seq.lua
index 1c08d20..3829f1b 100644
--- a/lua/pl/seq.lua
+++ b/lua/pl/seq.lua
@@ -209,10 +209,10 @@ function seq.random(n,l,u)
end
return function()
- if n == 0 then return nil
- else
- n = n - 1
+ if n == 0 then n = n - 1
return rand()
+ else... | [
"tests/test-seq.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | seq.random() returns nil immediately instead of generating random numbers
Description
The `seq.random(n, l, u)` function is supposed to generate a sequence of `n` random numbers between `l` and `u`, but it's currently returning `nil` on the first call instead of generating any random numbers.
For example:
```lua
lo... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__rnbbscyu | diff --git a/lua/pl/config.lua b/lua/pl/config.lua
index ebd531c..fed4b05 100644
--- a/lua/pl/config.lua
+++ b/lua/pl/config.lua
@@ -57,12 +57,12 @@ function config.lines(file)
local f,openf,err
local line = ''
if type(file) == 'string' then
+ f = file or io.stdin
+ if not file.read then re... | [
"tests/test-config.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lu... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the `config.lines()` function has been modified in a way that breaks its functionality. The test output shows an error: `Error: /testbed/lua/pl/config.lua:63: bad argument #1 to 'open' (string expected, got table)`.
Let me analyze the patch to understand what's happ... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__rtn0pohn | diff --git a/lua/pl/class.lua b/lua/pl/class.lua
index cd041c8..035183e 100644
--- a/lua/pl/class.lua
+++ b/lua/pl/class.lua
@@ -132,10 +132,10 @@ local function _class(base,c_arg,c)
-- can define class by passing it a plain table of methods
local plain = type(base) == 'table' and not getmetatable(base)
... | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"tests/test-list2.lua",
"tests/test-map.lua",
"test... | [
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-path.lua",
"tests/test-pretty.lua",
"tests/test-sip.lua",
"tests/test-stringio.lua",
"tests/test-url.lua",
"tests/test-utils2.lua",
"tests/test-xml.lua"
] | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | [Bug]: Class creation fails with "attempt to index a nil value" when base class is provided
### Bug summary
When creating a class with inheritance (passing a base class), the class creation fails with an error "attempt to index a nil value (local 'c')". This breaks most class-based functionality in the library.
### ... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__ss6dicob | diff --git a/lua/pl/sip.lua b/lua/pl/sip.lua
index 5d1f2aa..09584a2 100644
--- a/lua/pl/sip.lua
+++ b/lua/pl/sip.lua
@@ -208,12 +208,12 @@ function sip.create_spec_fun(spec,options)
var = var..':sub(2,-2)'
end
if named_vars then
- fun = ('%s\tres.%s = %s\n'):for... | [
"tests/test-lapp.lua",
"tests/test-sip.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lexer.lua",
"tests/test-list.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the issue is related to the `sip` module's handling of named variables. The test output shows that when using named variables, the function is returning an indexed array instead of a table with named fields.
Here's the GitHub issue:
---
sip.create_spec_fun() retur... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__tl0azw2p | diff --git a/lua/pl/seq.lua b/lua/pl/seq.lua
index 1c08d20..517cdde 100644
--- a/lua/pl/seq.lua
+++ b/lua/pl/seq.lua
@@ -250,8 +250,8 @@ function seq.count_map(iter)
local v
for s in default_iter(iter) do
v = t[s]
- if v then t[s] = v + 1
- else t[s] = 1 end
+ if v then t[s] = 1
... | [
"tests/test-seq.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the `seq.count_map` function has a logic error where the `if` and `else` branches have been swapped incorrectly, causing an arithmetic operation on a nil value.
<issue>
seq.count_map produces error when counting elements
Description
When using `seq.count_map` to ... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__uo6470pg | diff --git a/lua/pl/tablex.lua b/lua/pl/tablex.lua
index 3606912..9eba15b 100644
--- a/lua/pl/tablex.lua
+++ b/lua/pl/tablex.lua
@@ -562,6 +562,8 @@ function tablex.pairmap(fun,t,...)
for k,v in pairs(t) do
local rv,rk = fun(k,v,...)
if rk then
+ res[#res+1] = rv
+ else
... | [
"tests/test-map.lua",
"tests/test-tablex.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the `tablex.pairmap` function has a logic error that causes it to fail when the mapping function returns a key (`rk`). The test output shows errors like "table index is nil" occurring in `tablex.lua:574`.
Let me create a realistic GitHub issue mimicking the demonstr... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__wasb9h4z | diff --git a/lua/pl/stringx.lua b/lua/pl/stringx.lua
index 3fb8a75..011deff 100644
--- a/lua/pl/stringx.lua
+++ b/lua/pl/stringx.lua
@@ -831,6 +831,9 @@ do
if (s:find("\n") or equal_signs) and not s:find("\r") then
-- If there is an embedded sequence that matches a long quote, then
-- find ... | [
"tests/test-pretty.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | [Bug]: stringx.quote() incorrectly handles strings with newlines and long bracket sequences
### Bug summary
The `stringx.quote()` function is producing incorrect output for strings that contain both newlines and sequences that could match long bracket delimiters. Instead of using long bracket notation, it's falling b... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__xq6g18aw | diff --git a/lua/pl/Date.lua b/lua/pl/Date.lua
index 039dbaf..15da14b 100644
--- a/lua/pl/Date.lua
+++ b/lua/pl/Date.lua
@@ -339,8 +339,8 @@ function Date.Interval:set(t)
end
local function ess(n)
- if n > 1 then return 's '
- else return ' '
+ if n > 1 then return ' '
+ else return 's '
end
end
... | [
"tests/test-date.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Date.Interval pluralization is backwards
I'm getting incorrect pluralization when formatting date intervals. When I have exactly 1 unit of time, it's showing the plural form with 's', and when I have multiple units, it's showing the singular form without 's'.
For example:
```lua
local Date = require 'pl.Date'
local i... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_invert_if__zivrvtyp | diff --git a/lua/pl/func.lua b/lua/pl/func.lua
index 4fdfb46..b0c5d64 100644
--- a/lua/pl/func.lua
+++ b/lua/pl/func.lua
@@ -257,6 +257,8 @@ func.repr = repr
local collect_values
function collect_values (e,vlist)
if isPE(e) then
+ return 0
+ else -- plain value has no placeholder dependence
if... | [
"tests/test-data.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the code in `lua/pl/func.lua` has been modified in the `collect_values` function. The logic for handling `isPE(e)` has been changed - the early return of `0` was moved from the else branch to the if branch, which inverts the logic.
The test output shows a failure in... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__1plx58bg | diff --git a/lua/pl/stringx.lua b/lua/pl/stringx.lua
index 3fb8a75..4e27129 100644
--- a/lua/pl/stringx.lua
+++ b/lua/pl/stringx.lua
@@ -229,12 +229,6 @@ end
-- @section find
local function _find_all(s,sub,first,last,allow_overlap)
- first = first or 1
- last = last or #s
- if sub == '' then return last+1,... | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"tests/test-list2.lua... | [
"tests/test-class3.lua",
"tests/test-class4.lua"
] | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Syntax error in stringx.lua: 'end' expected (to close 'function' at line 231)
I'm getting a syntax error when trying to use the `pl.stringx` module. The error message is:
```
error loading module 'pl.stringx' from file '/testbed/lua/pl/stringx.lua':
/testbed/lua/pl/stringx.lua:248: 'end' expected (to close 'function... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__4ge14fpc | diff --git a/lua/pl/tablex.lua b/lua/pl/tablex.lua
index 3606912..6f28fcc 100644
--- a/lua/pl/tablex.lua
+++ b/lua/pl/tablex.lua
@@ -96,19 +96,19 @@ function tablex.copy (t)
end
local function cycle_aware_copy(t, cache)
- if type(t) ~= 'table' then return t end
- if cache[t] then return cache[t] end
asse... | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"tests/test-list2.lua... | [
"tests/test-class3.lua",
"tests/test-class4.lua"
] | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the code in `lua/pl/tablex.lua` has been scrambled, causing a syntax error. The function `cycle_aware_copy` has its lines reordered in a way that breaks the Lua syntax.
Let me write a realistic GitHub issue mimicking the demonstration style:
---
## tablex module f... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__582645bb | diff --git a/lua/pl/List.lua b/lua/pl/List.lua
index a65cf3b..2ab4a29 100644
--- a/lua/pl/List.lua
+++ b/lua/pl/List.lua
@@ -242,8 +242,8 @@ end
--- Empty the list.
-- @return the list
function List:clear()
- for i=1,#self do tremove(self) end
return self
+for i=1,#self do tremove(self) end
end
local eps... | [
"tests/test-__vector.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"tests/test-list2.lua",
"tests/test-map.lua",
"tests/test-orderedmap.lua",
"tests/test-seq.lua",
"tests/test-tablex.lua",
"te... | [
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-path.lua",
"tests/test-pretty.lua",
"tests/test-sip.lua",
"tests/test-stringio.lua",
"tests/test-url.lua",
"tests/test-utils2.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | ## List:clear() method broken - syntax error in function
I'm encountering a syntax error when trying to use the `List` module. It seems like there's a problem with the `clear()` method that's preventing the entire module from loading.
**How to reproduce:**
Try to use any functionality from `pl.List`:
```lua
local L... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__80u78ju3 | diff --git a/lua/pl/luabalanced.lua b/lua/pl/luabalanced.lua
index a1f7dc6..6c22dc6 100644
--- a/lua/pl/luabalanced.lua
+++ b/lua/pl/luabalanced.lua
@@ -188,14 +188,14 @@ M.match_expression = match_expression
-- but returns array as match.
local function match_namelist(s, pos)
pos = pos or 1
- local list = {}
- ... | [
"tests/test-comprehension.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch, I can see that the code in `match_namelist` function has been incorrectly restructured - the `local list = {}` declaration has been moved to after the return statement, and the indentation of the while loop has been changed. This would cause the function to fail when called.
Let me create a reali... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__9k593s2s | diff --git a/lua/pl/List.lua b/lua/pl/List.lua
index a65cf3b..b5bcbc5 100644
--- a/lua/pl/List.lua
+++ b/lua/pl/List.lua
@@ -100,9 +100,9 @@ List.push = tinsert
-- @tparam List L Another List
-- @return the list
function List:extend(L)
- assert_arg(1,L,'table')
- for i = 1,#L do tinsert(self,L[i]) end
ret... | [
"tests/test-__vector.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"tests/test-list2.lua",
"tests/test-map.lua",
"tests/test-orderedmap.lua",
"tests/test-seq.lua",
"tests/test-tablex.lua",
"te... | [
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-path.lua",
"tests/test-pretty.lua",
"tests/test-sip.lua",
"tests/test-stringio.lua",
"tests/test-url.lua",
"tests/test-utils2.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Syntax error in List.lua breaks module loading
**What happened**:
The `pl.List` module fails to load with a syntax error. Many tests that depend on this module are now failing with the error:
```
Error: error loading module 'pl.List' from file '/testbed/lua/pl/List.lua':
/testbed/lua/pl/List.lua:104: 'end' expected (... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__d4i2ko91 | diff --git a/lua/pl/path.lua b/lua/pl/path.lua
index 011b979..861435f 100644
--- a/lua/pl/path.lua
+++ b/lua/pl/path.lua
@@ -404,9 +404,6 @@ end
-- An empty path results in '.'.
-- @string P a file path
function path.normpath(P)
- assert_string(1,P)
- -- Split path into anchor and relative path.
- local anc... | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"tests/test-list2.lua... | [
"tests/test-class3.lua",
"tests/test-class4.lua"
] | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | # Syntax error in path.normpath() function
Hi there,
I've encountered what appears to be a syntax error in the `path.normpath()` function in `lua/pl/path.lua`. When trying to use the library, I'm getting a Lua parsing error that prevents the module from loading at all.
The error message I'm seeing is:
```
error loa... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__g8i7d6ff | diff --git a/lua/pl/lapp.lua b/lua/pl/lapp.lua
index 3bd752d..4290053 100644
--- a/lua/pl/lapp.lua
+++ b/lua/pl/lapp.lua
@@ -194,8 +194,8 @@ function lapp.process_options_string(str,args)
end
local function set_result(ps,parm,val)
- parm = type(parm) == "string" and parm:gsub("%W", "_") or parm -- so... | [
"tests/test-lapp.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lexer.lua",
"tests/test-list.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the code change moved the parameter name normalization (converting `foo-bar` to `foo_bar`) to happen AFTER the result is set, rather than BEFORE. This causes parameters with dashes to be stored with their original names instead of the normalized underscore versions.
... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__je7y06a9 | diff --git a/lua/pl/utils.lua b/lua/pl/utils.lua
index ca2a022..53be13d 100644
--- a/lua/pl/utils.lua
+++ b/lua/pl/utils.lua
@@ -358,11 +358,28 @@ end
-- os.exit(1)
-- end
function utils.enum(...)
- local first = select(1, ...)
- local enum = {}
- local lst
-
- if type(first) ~= "table" then
+ setmetatable(en... | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"tests/test-list2.lua... | [
"tests/test-class3.lua",
"tests/test-class4.lua"
] | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | ## Syntax error in utils.lua after recent changes
I'm getting a syntax error when trying to load the `pl.utils` module. The error message is:
```
error loading module 'pl.utils' from file '/testbed/lua/pl/utils.lua':
/testbed/lua/pl/utils.lua:416: 'end' expected (to close 'function' at line 360) near 'local'
```
Th... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__jv5hlmke | diff --git a/lua/pl/stringx.lua b/lua/pl/stringx.lua
index 3fb8a75..4c3ec76 100644
--- a/lua/pl/stringx.lua
+++ b/lua/pl/stringx.lua
@@ -535,9 +535,9 @@ end
-- Three
-- ]])
function stringx.dedent (s)
- assert_arg(1,s,'string')
- local lst = usplit(s,'\n')
- if #lst>0 then
+ return concat(lst,'\n')..'\n'
+local ... | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"tests/test-list2.lua... | [
"tests/test-class3.lua",
"tests/test-class4.lua"
] | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the code in `stringx.lua` has been corrupted with statements appearing in the wrong order, causing a syntax error. Let me create a realistic GitHub issue mimicking the demonstration style:
---
stringx module fails to load with syntax error
The `pl.stringx` module ... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__l11zqd4l | diff --git a/lua/pl/data.lua b/lua/pl/data.lua
index 67b8d71..6245ecc 100644
--- a/lua/pl/data.lua
+++ b/lua/pl/data.lua
@@ -469,9 +469,6 @@ end
local function process_select (data,parms)
--- preparing fields ----
- field_error = nil
- local fields = parms.fields
- local numfields = fields:find '%$' o... | [
"tests/test-data.lua",
"tests/test-data2.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"tests/test-list2.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | [Bug]: Syntax error in data.lua after recent changes
### Bug summary
The `pl.data` module fails to load with a syntax error after recent changes. The error indicates that an `end` statement is expected to close a function, but the code structure appears to be broken.
### Code for reproduction
```lua
local data = re... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__lkb0y4uz | diff --git a/lua/pl/tablex.lua b/lua/pl/tablex.lua
index 3606912..fe8ad7e 100644
--- a/lua/pl/tablex.lua
+++ b/lua/pl/tablex.lua
@@ -870,14 +870,8 @@ end
-- @int[opt] position (default is at end)
-- @array values
function tablex.insertvalues(t, ...)
- assert_arg(1,t,'table')
local pos, values
- if select(... | [
"tests/test-tablex.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | ## `tablex.insertvalues` crashes when called with values argument
### Bug description
The `tablex.insertvalues` function crashes with an error when trying to insert values into a table. The function attempts to access the `values` variable before it has been assigned, causing a "attempt to get length of a nil value" ... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__nlvczpxb | diff --git a/lua/pl/array2d.lua b/lua/pl/array2d.lua
index 0bc910e..8c6c26b 100644
--- a/lua/pl/array2d.lua
+++ b/lua/pl/array2d.lua
@@ -161,13 +161,13 @@ end
-- @usage product('..',{1,2},{'a','b'}) == {{'1a','2a'},{'1b','2b'}}
function array2d.product (f,t1,t2)
f = utils.function_arg(1,f)
- assert_arg(2,t1,'... | [
"tests/test-data.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Syntax error in array2d.product function breaks module loading
The `pl.array2d` module fails to load with a syntax error:
```
Error: error loading module 'pl.array2d' from file '/testbed/lua/pl/array2d.lua':
/testbed/lua/pl/array2d.lua:170: 'end' expected (to close 'function' at line 162) near 'local'
```
This appe... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__oypz6ds2 | diff --git a/lua/pl/tablex.lua b/lua/pl/tablex.lua
index 3606912..7cbb051 100644
--- a/lua/pl/tablex.lua
+++ b/lua/pl/tablex.lua
@@ -693,11 +693,12 @@ end
-- @return a map-like table
-- @see seq.count_map
function tablex.count_map (t,cmp)
- assert_arg_indexable(1,t)
- local res,mask = {},{}
- cmp = function... | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"tests/test-list2.lua... | [
"tests/test-class3.lua",
"tests/test-class4.lua"
] | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | [Bug]: Syntax error in tablex.lua - module fails to load
### Bug summary
After a recent change, the `pl.tablex` module fails to load with a syntax error. The error message indicates that an 'end' is expected to close a function, but instead encounters 'cmp' on line 697. This prevents the entire module from being load... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__rc0fwrl3 | diff --git a/lua/pl/tablex.lua b/lua/pl/tablex.lua
index 3606912..9b188d0 100644
--- a/lua/pl/tablex.lua
+++ b/lua/pl/tablex.lua
@@ -722,17 +722,17 @@ end
-- @func pred a boolean function
-- @param arg optional argument to be passed as second argument of the predicate
function tablex.filter (t,pred,arg)
- assert_... | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"tests/test-list2.lua... | [
"tests/test-class3.lua",
"tests/test-class4.lua"
] | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Cannot load pl.tablex module - syntax error in tablex.lua
Attempting to require the `pl.tablex` module results in a syntax error. The module fails to load with an error about an unexpected 'for' keyword.
## Expected Result
The module should load successfully and be usable:
```lua
local tablex = require 'pl.tablex'
... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__s7d4fdmw | diff --git a/lua/pl/List.lua b/lua/pl/List.lua
index a65cf3b..cdf1644 100644
--- a/lua/pl/List.lua
+++ b/lua/pl/List.lua
@@ -463,12 +463,12 @@ end
-- @see pl.seq.mapmethod
function List:mapm (name,...)
local res = {}
- for i = 1,#self do
+return makelist(res,self)
+for i = 1,#self do
local val = self[i... | [
"tests/test-__vector.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"tests/test-list2.lua",
"tests/test-map.lua",
"tests/test-orderedmap.lua",
"tests/test-seq.lua",
"tests/test-tablex.lua",
"te... | [
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-path.lua",
"tests/test-pretty.lua",
"tests/test-sip.lua",
"tests/test-stringio.lua",
"tests/test-url.lua",
"tests/test-utils2.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Syntax error in List.lua breaks module loading
The `pl.List` module fails to load with a syntax error. When trying to require the module, I get:
```
error loading module 'pl.List' from file '/testbed/lua/pl/List.lua':
/testbed/lua/pl/List.lua:467: 'end' expected (to close 'function' at line 464) near 'for'
```
This... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__t50ynipx | diff --git a/lua/pl/path.lua b/lua/pl/path.lua
index 011b979..270653e 100644
--- a/lua/pl/path.lua
+++ b/lua/pl/path.lua
@@ -543,18 +543,6 @@ end
-- @string path2 a file path
-- @return the common prefix (Windows: separators will be normalized, casing will be original)
function path.common_prefix (path1,path2)
- ... | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"tests/test-list2.lua... | [
"tests/test-class3.lua",
"tests/test-class4.lua"
] | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Syntax error in path.lua breaks module loading
The `pl.path` module cannot be loaded due to a syntax error in the `common_prefix` function. When trying to require the module, I get this error:
```
error loading module 'pl.path' from file '/testbed/lua/pl/path.lua':
/testbed/lua/pl/path.lua:565: 'end' expected (to cl... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__y0dtx4tg | diff --git a/lua/pl/xml.lua b/lua/pl/xml.lua
index 3f49c49..c862c53 100644
--- a/lua/pl/xml.lua
+++ b/lua/pl/xml.lua
@@ -1097,9 +1097,10 @@ do
if ret and #pat > 0 then
local i,j = 1,1
local function next_elem()
- j = j + 1 -- next child ... | [
"tests/test-xml.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Syntax error in xml.lua after code reformatting
I was working with the xml module and encountered a syntax error that prevents the module from loading at all. When trying to require the module, I get:
```
Error: error loading module 'pl.xml' from file '/testbed/lua/pl/xml.lua':
/testbed/lua/pl/xml.lua:1101: 'end' ex... |
lunarmodules__penlight.bd26cb9e.func_pm_ctrl_shuffle__z1vz0672 | diff --git a/lua/pl/xml.lua b/lua/pl/xml.lua
index 3f49c49..05e75de 100644
--- a/lua/pl/xml.lua
+++ b/lua/pl/xml.lua
@@ -533,8 +533,6 @@ end
-- @tparam function callback a function with signature `function(node)`, passed the node.
-- The element will be updated with the returned value, or deleted if it returns `nil`.... | [
"tests/test-xml.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | [BUG] Syntax error in xml.lua maptags function
#### What happened?
After a recent change, the `pl.xml` module fails to load with a syntax error. When trying to require or use the xml module, I get the following error:
```
Error: error loading module 'pl.xml' from file '/testbed/lua/pl/xml.lua':
/testbed/lua/pl/xml.... |
lunarmodules__penlight.bd26cb9e.func_pm_flip_operators__1p9hugww | diff --git a/lua/pl/Date.lua b/lua/pl/Date.lua
index 039dbaf..720c245 100644
--- a/lua/pl/Date.lua
+++ b/lua/pl/Date.lua
@@ -244,7 +244,7 @@ function Date:add(t)
local key,val = next(t)
self.tab[key] = self.tab[key] + val
self:set(os_time(self.tab))
- if old_dst ~= self.tab.isdst then
+ if old_dst ... | [
"tests/test-date.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Date.add() incorrectly adjusts hour when DST status doesn't change
**To Reproduce**
When adding time to a Date object that crosses a DST boundary, the hour adjustment logic appears to be inverted. The issue occurs when the DST status remains the same before and after the addition.
Here's a minimal example:
```lua
l... |
lunarmodules__penlight.bd26cb9e.func_pm_flip_operators__334rcr3l | diff --git a/lua/pl/xml.lua b/lua/pl/xml.lua
index 3f49c49..fa222b8 100644
--- a/lua/pl/xml.lua
+++ b/lua/pl/xml.lua
@@ -1036,7 +1036,7 @@ do
end
-- a table with only one pair {[0]=value} shall be reduced to that value
local numkey,val = has_one_element(tbl)
- i... | [
"tests/test-xml.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | XML parsing returns empty table when converting elements with single numeric key
I'm experiencing an issue with the XML parsing functionality in Penlight. When parsing XML documents that contain repeated elements (which should be converted to arrays), the parser is returning empty tables instead of the expected array ... |
lunarmodules__penlight.bd26cb9e.func_pm_flip_operators__6a3vgt04 | diff --git a/lua/pl/List.lua b/lua/pl/List.lua
index a65cf3b..619c82c 100644
--- a/lua/pl/List.lua
+++ b/lua/pl/List.lua
@@ -55,7 +55,7 @@ function List._create (src)
end
function List:_init (src)
- if self == src then return end -- existing table used as self!
+ if self ~= src then return end -- existing tab... | [
"tests/test-__vector.lua",
"tests/test-data.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"tests/test-list2.lua",
"tests/test-orderedmap.lua",
"tests/test-template.lua"
] | [
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-map.lua",
"tests/test-path.lua",
"tests/test-pretty.lua"... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | List initialization broken when passing existing table
When creating a `List` from an existing table, the list ends up empty instead of being populated with the table's contents. This appears to affect multiple operations that rely on list initialization.
**To Reproduce**
```lua
local List = require 'pl.List'
-- Cr... |
lunarmodules__penlight.bd26cb9e.func_pm_flip_operators__6c95piws | diff --git a/lua/pl/xml.lua b/lua/pl/xml.lua
index 3f49c49..1858a29 100644
--- a/lua/pl/xml.lua
+++ b/lua/pl/xml.lua
@@ -80,10 +80,10 @@ local function is_tag(d) return type(d) == 'table' and is_text(d.tag) end
-- local doc = xml.new("main", { hello = "world", answer = "42" })
-- print(doc) --> <main hello='world' ... | [
"tests/test-xml.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the `xml.new()` function has introduced a bug. The logic for validating the `tag` parameter has been inverted, and the `attr` parameter handling has been broken. Let me create a realistic GitHub issue mimicking the demonstration style.
---
xml.new() throws error wh... |
lunarmodules__penlight.bd26cb9e.func_pm_flip_operators__7ayin4qm | diff --git a/lua/pl/sip.lua b/lua/pl/sip.lua
index 5d1f2aa..df3aa7b 100644
--- a/lua/pl/sip.lua
+++ b/lua/pl/sip.lua
@@ -98,7 +98,7 @@ function sip.create_pattern (spec,options)
assert_arg(1,spec,'string')
local fieldnames,fieldtypes = {},{}
- if type(spec) == 'string' then
+ if type(spec) ~= 'string'... | [
"tests/test-lapp.lua",
"tests/test-sip.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lexer.lua",
"tests/test-list.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the `sip.lua` module has been broken by multiple logic inversions and incorrect operators. The test output shows that `test-sip.lua` is failing with an assertion error where it expected to parse a pattern and extract fields but got an empty table instead.
Let me cre... |
lunarmodules__penlight.bd26cb9e.func_pm_flip_operators__8dd2u1v8 | diff --git a/lua/pl/input.lua b/lua/pl/input.lua
index f81de87..2bc7676 100644
--- a/lua/pl/input.lua
+++ b/lua/pl/input.lua
@@ -114,9 +114,9 @@ function input.fields (ids,delim,f,opts)
local sep
local s
local getter = input.create_getter(f)
- local no_fail = opts and opts.no_fail
+ local no_fail = opts or o... | [
"tests/test-seq.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the `input.fields` function in `lua/pl/input.lua` has been modified with several logic errors. The test output shows an error: `/testbed/lua/pl/input.lua:117: attempt to index a nil value (local 'opts')`.
Let me create a realistic GitHub issue mimicking the demonstr... |
lunarmodules__penlight.bd26cb9e.func_pm_flip_operators__9pocziy0 | diff --git a/lua/pl/luabalanced.lua b/lua/pl/luabalanced.lua
index a1f7dc6..788777f 100644
--- a/lua/pl/luabalanced.lua
+++ b/lua/pl/luabalanced.lua
@@ -111,16 +111,16 @@ M.match_bracketed = match_bracketed
-- Function interface is similar to match_string.
local function match_comment(s, pos)
pos = pos or 1
- if ... | [
"tests/test-comprehension.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | Looking at the patch and test output, I can see that the `luabalanced.lua` file has been modified with some problematic changes. The patch shows that string concatenation operators (`..`) were changed to addition operators (`+`), and a substring index was changed from `pos+1` to `pos-1`. Let me create a realistic GitHu... |
lunarmodules__penlight.bd26cb9e.func_pm_flip_operators__b2ea0nps | diff --git a/lua/pl/pretty.lua b/lua/pl/pretty.lua
index df9a923..62dbf77 100644
--- a/lua/pl/pretty.lua
+++ b/lua/pl/pretty.lua
@@ -59,17 +59,17 @@ end
local function tostring(value)
if type(value) ~= "number" then
return original_tostring(value)
- elseif value ~= value then
+ elseif value == valu... | [
"tests/test-map.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | [Bug]: pretty.tostring() incorrectly formats NaN and -Inf values
### Bug summary
The `pretty.tostring()` function is not correctly handling special numeric values like NaN and -Inf. When converting these values to strings, they are being formatted incorrectly.
### Code for reproduction
```lua
local pretty = require... |
lunarmodules__penlight.bd26cb9e.func_pm_flip_operators__dxoa1k0e | diff --git a/lua/pl/data.lua b/lua/pl/data.lua
index 67b8d71..51dc148 100644
--- a/lua/pl/data.lua
+++ b/lua/pl/data.lua
@@ -352,7 +352,7 @@ function data.write (data,file,fieldnames,delim)
fieldnames = data.fieldnames
end
delim = delim or '\t'
- if fieldnames and #fieldnames > 0 then
+ if fiel... | [
"tests/test-data.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | [Bug]: data.write() not writing fieldnames header to file
### Bug summary
When using `data.write()` to export data to a file with fieldnames, the header row containing the field names is not being written to the output file. The data rows are written correctly, but the first line with column names is missing.
### Co... |
lunarmodules__penlight.bd26cb9e.func_pm_flip_operators__ftj2037t | diff --git a/lua/pl/luabalanced.lua b/lua/pl/luabalanced.lua
index a1f7dc6..c47414e 100644
--- a/lua/pl/luabalanced.lua
+++ b/lua/pl/luabalanced.lua
@@ -191,9 +191,9 @@ local function match_namelist(s, pos)
local list = {}
while 1 do
local c = #list == 0 and '^' or '^%s*,%s*'
- local item, post = s:match(... | [
"tests/test-comprehension.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.lua",
"tests/test-list.lua",
"... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | **Describe the bug**
The `match_namelist` function in `luabalanced.lua` is broken and causes a runtime error when parsing Lua code with list comprehensions or similar constructs that use name lists.
**To Reproduce**
Try to use list comprehensions or any feature that relies on parsing name lists:
```lua
local compre... |
lunarmodules__penlight.bd26cb9e.func_pm_flip_operators__iu8wtywz | diff --git a/lua/pl/sip.lua b/lua/pl/sip.lua
index 5d1f2aa..0524a1a 100644
--- a/lua/pl/sip.lua
+++ b/lua/pl/sip.lua
@@ -191,33 +191,33 @@ function sip.create_spec_fun(spec,options)
local ls = {}
spec,fieldnames,fieldtypes = sip.create_pattern(spec,options)
if not spec then return spec,fieldnames end
- ... | [
"tests/test-lapp.lua",
"tests/test-sip.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lexer.lua",
"tests/test-list.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | [Bug]: SIP pattern matching broken - attempt to add strings
### Bug summary
After a recent update, the SIP (String Input Patterns) module is completely broken. When trying to use any SIP pattern matching functionality, I get an error about attempting to add strings together.
### Code for reproduction
```lua
local s... |
lunarmodules__penlight.bd26cb9e.func_pm_flip_operators__kqv3vyld | diff --git a/lua/pl/seq.lua b/lua/pl/seq.lua
index 1c08d20..f769809 100644
--- a/lua/pl/seq.lua
+++ b/lua/pl/seq.lua
@@ -435,10 +435,10 @@ end
function seq.last (iter)
iter = default_iter(iter)
local val, l = iter(), nil
- if val == nil then return list{} end
+ if val ~= nil then return list{} end
... | [
"tests/test-seq.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | `seq.last()` returns empty list instead of iterator for non-empty sequences
I'm encountering unexpected behavior with `seq.last()` when working with sequences. The function is supposed to return an iterator that yields pairs of consecutive elements (current value and previous value), but instead it's returning an empt... |
lunarmodules__penlight.bd26cb9e.func_pm_flip_operators__p2p8auot | diff --git a/lua/pl/seq.lua b/lua/pl/seq.lua
index 1c08d20..4091fc1 100644
--- a/lua/pl/seq.lua
+++ b/lua/pl/seq.lua
@@ -36,13 +36,13 @@ end
-- given any value, return a function(y) which returns true if y == x
-- @param x a value
function seq.equal_to(x)
- if type(x) == "number" then
+ if type(x) ~= "number" then... | [
"tests/test-seq.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | `seq.equal_to()` returns inverted logic
The `seq.equal_to()` function is returning the opposite of what it should. When I create a predicate function using `seq.equal_to(x)`, it returns `true` when values are NOT equal to `x`, and `false` when they ARE equal to `x`.
For example:
```lua
local seq = require 'pl.seq'
... |
lunarmodules__penlight.bd26cb9e.func_pm_flip_operators__phjvdhcm | diff --git a/lua/pl/List.lua b/lua/pl/List.lua
index a65cf3b..ba9abdc 100644
--- a/lua/pl/List.lua
+++ b/lua/pl/List.lua
@@ -208,9 +208,9 @@ end
function List:reverse()
local t = self
local n = #t
- for i = 1,n/2 do
+ for i = 1,n*2 do
t[i],t[n] = t[n],t[i]
- n = n - 1
+ n = n + 1... | [
"tests/test-list.lua",
"tests/test-list2.lua"
] | [
"tests/test-__vector.lua",
"tests/test-class.lua",
"tests/test-class3.lua",
"tests/test-class4.lua",
"tests/test-compat.lua",
"tests/test-comprehension.lua",
"tests/test-config.lua",
"tests/test-data.lua",
"tests/test-data2.lua",
"tests/test-date.lua",
"tests/test-lapp.lua",
"tests/test-lexer.... | mssun65/swesmith.arm64.lunarmodules_1776_penlight.bd26cb9e | dksd65/lunarmodules__Penlight.bd26cb9e | ### Bug report
**Bug summary**
The `List:reverse()` method produces incorrect results when reversing lists. Instead of properly reversing the list elements, it appears to only return a partial or corrupted version of the reversed list.
**Code for reproduction**
```lua
local List = require 'pl.List'
-- Test case 1:... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 6