PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: pinojs/pino (js)
Issue: Pino always show custom levels if they were added after the logging level is set
**Here's a test code**

```javascript
const pino = require('pino')({
  level: 'info'
})
pino.addLevel('verbose', 25)
pino.addLevel('silly', 5)

pino.fatal('fatal')
pino.error('error')
pino.warn('warn')
pino.info('info')
pino.verbose('verbose')
pino.debug('debug')
pino.trace('trace')
pino.silly('silly')
```

**Output**
```
{"pid":5484,"hostname":"bruno-All-Series","level":60,"time":1495832557805,"msg":"fatal","v":1}
{"pid":5484,"hostname":"bruno-All-Series","level":50,"time":1495832557806,"msg":"error","v":1}
{"pid":5484,"hostname":"bruno-All-Series","level":40,"time":1495832557807,"msg":"warn","v":1}
{"pid":5484,"hostname":"bruno-All-Series","level":30,"time":1495832557807,"msg":"info","v":1}
{"pid":5484,"hostname":"bruno-All-Series","level":25,"time":1495832557807,"msg":"verbose","v":1}
{"pid":5484,"hostname":"bruno-All-Series","level":5,"time":1495832557807,"msg":"silly","v":1}
```

**Ther last two lines shouldn't be printed.**

The workaround we found is to set the logging level after the addLevel calls:

```javascript
const pino = require('pino')()
pino.addLevel('verbose', 25)
pino.addLevel('silly', 5)
pino.level = 'info'

pino.fatal('fatal')
pino.error('error')
pino.warn('warn')
pino.info('info')
pino.verbose('verbose')
pino.debug('debug')
pino.trace('trace')
pino.silly('silly')
```

I'm not sure whether it is an undocumented requirement or a bug. Either way it would be nice do document or fix it. I wasted a few hours trying to fix it.
Pull request description: added levelVal check to addLevel function
Fixes #246 

Patch:
diff --git a/pino.js b/pino.js
index aef3b1e..323e033 100644
--- a/pino.js
+++ b/pino.js
@@ -233,7 +233,12 @@ function addLevel (name, lvl) {
   this.levels.values[name] = lvl
   this.levels.labels[lvl] = name
   this._lscache[lvl] = flatstr('"level":' + Number(lvl))
-  this[name] = tools.genLog(lvl)
+  Object.defineProperty(this, name, {
+    value: lvl < this._levelVal ? tools.noop : tools.genLog(lvl),
+    enumerable: true,
+    writable: true
+  })
+
   return true
 }
 Object.defineProperty(pinoPrototype, 'addLevel', {


Test patch:
diff --git a/test/addlevel.test.js b/test/addlevel.test.js
index fd9ceab..4cf1b7d 100644
--- a/test/addlevel.test.js
+++ b/test/addlevel.test.js
@@ -73,6 +73,20 @@ test('after the fact add level does not include lower levels', function (t) {
   log.foo('bar')
 })
 
+test('after the fact add of a lower level does not include it', function (t) {
+  t.plan(1)
+
+  var log = pino(sink(function (chunk, enc, cb) {
+    t.is(chunk.msg, 'bar')
+    cb()
+  }))
+
+  log.level = 'info'
+  log.addLevel('foo', 15)
+  log.info('bar')
+  log.foo('nope')
+})
+
 test('children can be set to custom level', function (t) {
   t.plan(2)
Repository: sirupsen/logrus (go)
Issue: Deadlock during Entry.Infof after upgrade to v1.5.0
Issue does not happen when using v1.4.2.
When I upgrade to v1.5.0 I get a deadlock immediately upon application startup.

Killing stack trace:
```
goroutine 1 [semacquire, 3 minutes]:
sync.runtime_SemacquireMutex(0xc000140034, 0x2078100, 0x1)
	/home/tzvatot/go/src/runtime/sema.go:71 +0x47
sync.(*Mutex).lockSlow(0xc000140030)
	/home/tzvatot/go/src/sync/mutex.go:138 +0xfc
sync.(*Mutex).Lock(...)
	/home/tzvatot/go/src/sync/mutex.go:81
github.com/sirupsen/logrus.(*MutexWrap).Lock(...)
	/home/tzvatot/go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/logger.go:53
github.com/sirupsen/logrus.(*Entry).WithFields(0xc0001b8ee0, 0xc000724f20, 0x0)
	/home/tzvatot/go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/entry.go:125 +0x68d
github.com/sirupsen/logrus.(*Entry).WithField(...)
	/home/tzvatot/go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/entry.go:120
github.com/onrik/logrus/filename.(*wrapper).Format(0xc0004271a0, 0xc0001b8ee0, 0x30, 0x23bc480, 0xc00053ac01, 0xc0003cef30, 0xc0006650c0)
	/home/tzvatot/go/pkg/mod/github.com/onrik/logrus@v0.0.0-20181225141908-a09d5cdcdc62/filename/filename.go:19 +0x184
github.com/sirupsen/logrus.(*Entry).write(0xc0001b8ee0)
	/home/tzvatot/go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/entry.go:277 +0xa1
github.com/sirupsen/logrus.Entry.log(0xc000140000, 0xc0003ceea0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/home/tzvatot/go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/entry.go:253 +0x1c1
github.com/sirupsen/logrus.(*Entry).Log(0xc0001b8cb0, 0x4, 0xc0006652e0, 0x1, 0x1)
	/home/tzvatot/go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/entry.go:289 +0xeb
github.com/sirupsen/logrus.(*Entry).Logf(0xc0001b8cb0, 0xc000000004, 0x27353c8, 0x8f, 0xc000665450, 0x1, 0x1)
	/home/tzvatot/go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/entry.go:335 +0xe2
github.com/sirupsen/logrus.(*Entry).Infof(...)
	/home/tzvatot/go/pkg/mod/github.com/sirupsen/logrus@v1.5.0/entry.go:348
```

Using go version go1.13.5 linux/amd64
Pull request description: Revert #1047
Effectively reverts #1047 to fix #1128, #1120, #1122 as many users are seeing deadlocks after updating to 1.5.0.

The potential reason being is that calling `WithFields` from within a Hook tries to acquire the same lock, which is already acquired by the hook

This will re-open #1046

Patch:
diff --git a/entry.go b/entry.go
index 27b14bf..f6e062a 100644
--- a/entry.go
+++ b/entry.go
@@ -122,8 +122,6 @@ func (entry *Entry) WithField(key string, value interface{}) *Entry {
 
 // Add a map of fields to the Entry.
 func (entry *Entry) WithFields(fields Fields) *Entry {
-	entry.Logger.mu.Lock()
-	defer entry.Logger.mu.Unlock()
 	data := make(Fields, len(entry.Data)+len(fields))
 	for k, v := range entry.Data {
 		data[k] = v


Test patch:
diff --git a/entry_test.go b/entry_test.go
index 30eddae..b98e14a 100644
--- a/entry_test.go
+++ b/entry_test.go
@@ -210,7 +210,7 @@ func TestEntryWithIncorrectField(t *testing.T) {
 
 	fn := func() {}
 
-	e := &Entry{Logger: New()}
+	e := Entry{}
 	eWithFunc := e.WithFields(Fields{"func": fn})
 	eWithFuncPtr := e.WithFields(Fields{"funcPtr": &fn})
Repository: d5/tengo (go)
Issue: panic: interface conversion: tengo.Object is *tengo.CompiledFunction, not *tengo.String
Having two source modules where the one uses the others gives panic.
```
package main

import (
	"fmt"

	"github.com/d5/tengo/v2"
	"github.com/d5/tengo/v2/stdlib"
)

func main() {

	script := tengo.NewScript([]byte(`
		module_a := import("module_a")
		module_b := import("module_b")
		module_b()
	`))
	mods := stdlib.GetModuleMap("json", "fmt", "math", "times")

	mods.AddSourceModule("module_a", []byte(`
		fubar := func(arr, low, n) {
		    i := low + 1
		    for i < n + 1 {
		    }
		}

		module_a := {
		    "fo": func(){}
		}

		export module_a
	`))

	mods.AddSourceModule("module_b", []byte(
		`export func(){
			module_a := import("module_a")
		}
	`))
	script.SetImports(mods)

	compiledFunc, err := script.Compile()
	if err != nil {
		panic(err)
	}

	fmt.Println("RUN")
	err = compiledFunc.Run()
	if err != nil {
		panic(err)
	}
}
```
Pull request description: fix a bug in bytecode optimization code
Fixes #289 

As @ozanh pointed out, this is a bug in Bytecode optimization code. While removing duplicate constants, some indexes were re-mapped 2+ times if duplicate CompiledFunctions exist.

@ozanh @geseq let me know what you guys think.

Patch:
diff --git a/bytecode.go b/bytecode.go
index cfd0d0b..f3049ce 100644
--- a/bytecode.go
+++ b/bytecode.go
@@ -97,6 +97,7 @@ func (b *Bytecode) RemoveDuplicates() {
 	var deduped []Object
 
 	indexMap := make(map[int]int) // mapping from old constant index to new index
+	fns := make(map[*CompiledFunction]int)
 	ints := make(map[int64]int)
 	strings := make(map[string]int)
 	floats := make(map[float64]int)
@@ -106,9 +107,14 @@ func (b *Bytecode) RemoveDuplicates() {
 	for curIdx, c := range b.Constants {
 		switch c := c.(type) {
 		case *CompiledFunction:
-			// add to deduped list
-			indexMap[curIdx] = len(deduped)
-			deduped = append(deduped, c)
+			if newIdx, ok := fns[c]; ok {
+				indexMap[curIdx] = newIdx
+			} else {
+				newIdx = len(deduped)
+				fns[c] = newIdx
+				indexMap[curIdx] = newIdx
+				deduped = append(deduped, c)
+			}
 		case *ImmutableMap:
 			modName := inferModuleName(c)
 			newIdx, ok := immutableMaps[modName]


Test patch:
diff --git a/vm_test.go b/vm_test.go
index d451726..0adefe7 100644
--- a/vm_test.go
+++ b/vm_test.go
@@ -2654,6 +2654,25 @@ export func(a) {
 	expectRun(t, `out = import("mod0")`,
 		Opts().Module("mod0", `for v:=0;;v++ { if v == 3 { break } } }`),
 		tengo.UndefinedValue)
+
+	// duplicate compiled functions
+	// NOTE: module "mod" has a function with some local variable, and it's
+	//  imported twice by the main script. That causes the same CompiledFunction
+	//  put in constants twice and the Bytecode optimization (removing duplicate
+	//  constants) should still work correctly.
+	expectRun(t, `
+m1 := import("mod")
+m2 := import("mod")
+out = m1.x
+	`,
+		Opts().Module("mod", `
+f1 := func(a, b) {
+	c := a + b + 1
+	return a + b + 1
+}
+export { x: 1 }
+`),
+		1)
 }
 
 func TestModuleBlockScopes(t *testing.T) {
Repository: goccy/go-json (go)
Issue: decode struct with pointer field must be nil when error
![image](https://github.com/goccy/go-json/assets/12197761/c667fdac-c225-4ca2-a355-d91fd77ba7b3)

This is useful when used with go-validator so that it is not validated with its default value
Pull request description: fix: decode struct with pointer must be nil
fix #472 

Patch:
diff --git a/internal/decoder/ptr.go b/internal/decoder/ptr.go
index de12e10..ae22994 100644
--- a/internal/decoder/ptr.go
+++ b/internal/decoder/ptr.go
@@ -85,6 +85,7 @@ func (d *ptrDecoder) Decode(ctx *RuntimeContext, cursor, depth int64, p unsafe.P
 	}
 	c, err := d.dec.Decode(ctx, cursor, depth, newptr)
 	if err != nil {
+		*(*unsafe.Pointer)(p) = nil
 		return 0, err
 	}
 	cursor = c


Test patch:
diff --git a/decode_test.go b/decode_test.go
index df914ed..8f32ced 100644
--- a/decode_test.go
+++ b/decode_test.go
@@ -197,6 +197,13 @@ func Test_Decoder(t *testing.T) {
 			assertEq(t, "interface{}", v.F, nil)
 			assertEq(t, "nilfunc", true, v.G == nil)
 		})
+		t.Run("struct.pointer must be nil", func(t *testing.T) {
+			var v struct {
+				A *int
+			}
+			json.Unmarshal([]byte(`{"a": "alpha"}`), &v)
+			assertEq(t, "struct.A", v.A, (*int)(nil))
+		})
 	})
 	t.Run("interface", func(t *testing.T) {
 		t.Run("number", func(t *testing.T) {
Repository: canjs/can-zone (js)
Issue: The ended hook should only ever be called once
Currently it's possible for it to be called multiple times, such as when an error occurs within the initial "run" task.
Pull request description: Ensure that ended is only called once.
In case waits are added and removed after the Zone's run promise is
complete, never call the "ended" hook again. Fixes #118

Patch:
diff --git a/lib/zone.js b/lib/zone.js
index a7f3d78..eea3710 100644
--- a/lib/zone.js
+++ b/lib/zone.js
@@ -249,7 +249,9 @@ Zone.prototype.wrap = function(fn, catchErrors){
 };
 
 Zone.prototype.end = function(){
-	this.execHook("ended");
+	if(!this.isResolved) {
+		this.execHook("ended");
+	}
 	var dfd = this.deferred;
 	if(this.errors.length) {
 		var error = this.errors[0];


Test patch:
diff --git a/test/test.js b/test/test.js
index c76e9ea..db7da1c 100644
--- a/test/test.js
+++ b/test/test.js
@@ -209,6 +209,23 @@ describe("new Zone", function(){
 			done();
 		});
 	});
+
+	it("the ended hook is only called once", function(done){
+		var count = 0;
+		new Zone({
+			ended: function() { count++; }
+		}).run(function(){
+			setTimeout(function(){}, 0);
+
+			throw new Error("some error");
+		})
+		.catch(function(){
+			setTimeout(function(){
+				assert.equal(count, 1, "Endeded called once");
+				done();
+			}, 10);
+		});
+	});
 });
 
 describe("Reusing zones", function(){
Repository: Yoctol/bottender (ts)
Issue: should not print handlerDidEnd in ConsoleBot fallback mode
```
You > ...
Bot > ...
Bot > handlerDidEnd: []
```
Pull request description: fix ConsoleBot handlerDidEnd
fix #251

Patch:
diff --git a/src/context/ConsoleContext.js b/src/context/ConsoleContext.js
index c170cdae..368d4762 100644
--- a/src/context/ConsoleContext.js
+++ b/src/context/ConsoleContext.js
@@ -16,6 +16,11 @@ type Options = {|
   fallbackMethods: boolean,
 |};
 
+const methodBlackList = [
+  'then', // promise
+  'handlerDidEnd', // context lifecycle
+];
+
 export default class ConsoleContext extends Context implements PlatformContext {
   _client: ConsoleClient;
   _event: ConsoleEvent;
@@ -36,8 +41,8 @@ export default class ConsoleContext extends Context implements PlatformContext {
           if (target[key]) {
             return target[key];
           }
-          // should return undefined when check if it is a promise
-          if (key === 'then') return;
+
+          if (methodBlackList.some(method => method === key)) return;
           return async (...args) => {
             await target._methodMissing(key, args);
           };


Test patch:
diff --git a/src/context/__tests__/ConsoleContext.spec.js b/src/context/__tests__/ConsoleContext.spec.js
index e2d88386..64b8eba1 100644
--- a/src/context/__tests__/ConsoleContext.spec.js
+++ b/src/context/__tests__/ConsoleContext.spec.js
@@ -105,6 +105,13 @@ describe('method missing', () => {
 
     expect(context.isHandled).toBe(true);
   });
+
+  it('should not proxy blacklisted methods', async () => {
+    const { context } = setup({ fallbackMethods: true });
+
+    expect(context.handlerDidEnd).toBeUndefined();
+    expect(context.then).toBeUndefined();
+  });
 });
 
 describe('#typing', () => {
Repository: vaskoz/dailycodingproblem-go (go)
Issue: Day 76
Good morning! Here's your coding interview problem for today.

This problem was asked by Google.

You are given an N by M 2D matrix of lowercase letters. Determine the minimum number of columns that can be removed to ensure that each row is ordered from top to bottom lexicographically. That is, the letter at each column is lexicographically later as you go down each row. It does not matter whether each row itself is ordered lexicographically.

For example, given the following table:
```
cba
daf
ghi
```
This is not ordered because of the a in the center. We can remove the second column to make it ordered:
```
ca
df
gi
```
So your function should return 1, since we only needed to remove 1 column.

As another example, given the following table:

```abcdef```
Your function should return 0, since the rows are already ordered (there's only one row).

As another example, given the following table:
```
zyx
wvu
tsr
```
Your function should return 3, since we would need to remove all the columns to order it.
Pull request description: Day76
Resolves #161 .

Patch:
diff --git a/README.md b/README.md
index fa8dc51..f422f86 100644
--- a/README.md
+++ b/README.md
@@ -85,3 +85,4 @@ problems from
 * [Day 73](https://github.com/vaskoz/dailycodingproblem-go/issues/155)
 * [Day 74](https://github.com/vaskoz/dailycodingproblem-go/issues/157)
 * [Day 75](https://github.com/vaskoz/dailycodingproblem-go/issues/159)
+* [Day 76](https://github.com/vaskoz/dailycodingproblem-go/issues/161)
diff --git a/day76/problem.go b/day76/problem.go
new file mode 100644
index 0000000..4789c58
--- /dev/null
+++ b/day76/problem.go
@@ -0,0 +1,21 @@
+package day76
+
+// MinRemoveColumns determines the minimum number of columns
+// that can be removed to ensure that each row is ordered
+// from top to bottom lexicographically.
+// Runs in O(M*N) checking all input values.
+func MinRemoveColumns(matrix [][]rune) int {
+	if len(matrix) < 2 {
+		return 0
+	}
+	removals := 0
+	for col := 0; col < len(matrix[0]); col++ {
+		for row := 1; row < len(matrix); row++ {
+			if matrix[row][col] < matrix[row-1][col] {
+				removals++
+				break
+			}
+		}
+	}
+	return removals
+}


Test patch:
diff --git a/day76/problem_test.go b/day76/problem_test.go
new file mode 100644
index 0000000..817e6e5
--- /dev/null
+++ b/day76/problem_test.go
@@ -0,0 +1,39 @@
+package day76
+
+import "testing"
+
+var testcases = []struct {
+	input    [][]rune
+	expected int
+}{
+	{[][]rune{
+		[]rune("cba"),
+		[]rune("daf"),
+		[]rune("ghi"),
+	}, 1},
+	{[][]rune{
+		[]rune("abcdef"),
+	}, 0},
+	{[][]rune{
+		[]rune("zyx"),
+		[]rune("wvu"),
+		[]rune("tsr"),
+	}, 3},
+}
+
+func TestMinRemoveColumns(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if result := MinRemoveColumns(tc.input); result != tc.expected {
+			t.Errorf("Expected %v got %v", tc.expected, result)
+		}
+	}
+}
+
+func BenchmarkMinRemoveColumns(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			MinRemoveColumns(tc.input)
+		}
+	}
+}
Repository: moment/luxon (js)
Issue: Invalid unit when giving quarters to diff method
Hello,
I found an issue when passing `quarters` unit to the `diff` method:

```
luxon.DateTime.local().diff(luxon.DateTime.fromMillis(0), 'quarters')

duration.js:324 Uncaught Error: Invalid unit undefined
    at normalizeUnit (duration.js:324)
    at normalizeObject (util.js:259)
    at Function.fromObject (duration.js:245)
    at _diff (diff.js:70)
    at DateTime.diff (datetime.js:1760)
    at <anonymous>:1:24
```

Pull request description: Add quarters to diff fix #776
Hello,
Made the changes required in PR #778 review

Patch:
diff --git a/src/impl/diff.js b/src/impl/diff.js
index 57246dc9..1b8afb36 100644
--- a/src/impl/diff.js
+++ b/src/impl/diff.js
@@ -13,6 +13,7 @@ function dayDiff(earlier, later) {
 function highOrderDiffs(cursor, later, units) {
   const differs = [
     ["years", (a, b) => b.year - a.year],
+    ["quarters", (a, b) => b.quarter - a.quarter],
     ["months", (a, b) => b.month - a.month + (b.year - a.year) * 12],
     [
       "weeks",


Test patch:
diff --git a/test/datetime/diff.test.js b/test/datetime/diff.test.js
index e4e29f3c..cb439b6f 100644
--- a/test/datetime/diff.test.js
+++ b/test/datetime/diff.test.js
@@ -25,6 +25,14 @@ test("DateTime#diff makes simple diffs", () => {
     years: 1
   });
 
+  expect(diffObjs({ year: 2016, month: 4 }, { year: 2016, month: 1 }, "quarters")).toEqual({
+    quarters: 1
+  });
+
+  expect(diffObjs({ year: 2017, month: 10 }, { year: 2017, month: 4 }, "quarters")).toEqual({
+    quarters: 2
+  });
+
   expect(
     diffObjs({ year: 2016, month: 6, day: 28 }, { year: 2016, month: 5, day: 28 }, "months")
   ).toEqual({ months: 1 });