PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: immerjs/immer (js)

Issue:
clear Map produces incorrect patches
## 🐛 Bug Report

clear Map produce incorrect patches

## Link to repro

codebox link: https://codesandbox.io/s/immer-sandbox-forked-zz8le

### immer source code
https://github.com/immerjs/immer/blob/bf90358c1bfedf0afb6e3bb016d6e6233b96e3ac/src/plugins/mapset.ts#L112
this line clears the `assigned_`, and Patch Plugin gen patches depends on `each(state.assigned_)`

https://github.com/immerjs/immer/blob/bf90358c1bfedf0afb6e3bb016d6e6233b96e3ac/src/plugins/patches.ts#L121-L143

is this by design? or a bug.

## To Reproduce

just run the  codesanbox link  above

## Observed behavior

`changes` is a empty array.

## Expected behavior

`changes` is `[{ type: 'Remove', path: ['t2', 't'] }]`

## Environment

We only accept bug reports against the latest Immer version.

- **Immer version:**
- [x] I filed this report against the _latest_ version of Immer
- [x] Occurs with `setUseProxies(true)`
- [ ] Occurs with `setUseProxies(false)` (ES5 only)


Pull request:
set assigned keys when clear map
fix #663 

Patch:
diff --git a/src/plugins/mapset.ts b/src/plugins/mapset.ts
index 8bb2d09..6dd579a 100644
--- a/src/plugins/mapset.ts
+++ b/src/plugins/mapset.ts
@@ -15,7 +15,8 @@ import {
 	markChanged,
 	ProxyTypeMap,
 	ProxyTypeSet,
-	die
+	die,
+	each
 } from "../internal"
 
 export function enableMapSet() {
@@ -110,6 +111,9 @@ export function enableMapSet() {
 			prepareMapCopy(state)
 			markChanged(state)
 			state.assigned_ = new Map()
+			each(state.base_, key => {
+				state.assigned_!.set(key, false)
+			})
 			return state.copy_!.clear()
 		}
 


Test patch:
diff --git a/__tests__/map-set.js b/__tests__/map-set.js
index faa4680..bbe9d47 100644
--- a/__tests__/map-set.js
+++ b/__tests__/map-set.js
@@ -244,5 +244,27 @@ function runBaseTest(name, useProxies, autoFreeze, useListener) {
 			expect(map1.has("key")).toBe(true)
 			expect(map1.get("key")).toBe(undefined)
 		})
+
+		test("#663 - clear map", () => {
+			const map = new Map([
+				["a", "b"],
+				["b", "c"]
+			])
+			const result = produceWithPatches(map, draft => {
+				draft.clear()
+			})
+
+			expect(result).toEqual([
+				new Map(),
+				[
+					{op: "remove", path: ["a"]},
+					{op: "remove", path: ["b"]}
+				],
+				[
+					{op: "add", path: ["a"], value: "b"},
+					{op: "add", path: ["b"], value: "c"}
+				]
+			])
+		})
 	})
 }
Repository: styled-system/styled-system (js)

Issue:
Inheriting configs
Hey 👋 

Im creating my own Style Function API on top of SS v5.

Without going too deep into why I'm doing this, I've created this minimal example to reproduce the issue: https://codesandbox.io/s/styled-system-issue-inheriting-configs-p3ibv

> Note: The example above is dumb, please don't fixate too much on it. 

Basically, I'm importing the `border` function from SS and then creating my own `border` function based off its `config`.

Surprisingly the `borderRadius` prop stops working. 

I've been knocking my head against the wall trying to figure out _why_ - but no luck (and now I have a headache)

Does this make sense to anyone?

Pull request:
Fix parser config
Fixes #565

Patch:
diff --git a/packages/core/src/index.js b/packages/core/src/index.js
index 1121fe1..c146eb1 100644
--- a/packages/core/src/index.js
+++ b/packages/core/src/index.js
@@ -140,6 +140,10 @@ export const system = (args = {}) => {
       })
       return
     }
+    if (typeof conf === 'function') {
+      config[key] = conf
+      return
+    }
     config[key] = createStyleFunction(conf)
   })
 


Test patch:
diff --git a/packages/core/test/system.js b/packages/core/test/system.js
index d498985..0fdbb12 100644
--- a/packages/core/test/system.js
+++ b/packages/core/test/system.js
@@ -178,3 +178,19 @@ test('skips null values in arrays', () => {
     }
   })
 })
+
+test('parser configs can be composed manually', () => {
+  const color = system({ color: true, backgroundColor: true })
+  const layout = system({ width: true, height: true })
+  const composed = system({ ...color.config, ...layout.config })
+  const style = composed({
+    color: 'tomato',
+    backgroundColor: 'black',
+    width: '100%',
+  })
+  expect(style).toEqual({
+    color: 'tomato',
+    backgroundColor: 'black',
+    width: '100%',
+  })
+})
Repository: reduxjs/react-redux (ts)

Issue:
selector in useSelector called one more time after forceUpdate inside hook
**What is the current behavior?**

When state changed, selector recomputes, and value sets into latestSelectedState. Component will re-render, and selector recomputes again, but its value already in latestSelectedState.current

(selector is arrow function - `const data = useSelector((state) => state.data);`)

**What is the expected behavior?**

Selector recomputes once

I can open PR to fix this, but I don't know, may be selector specially calls twice for some reasons

Pull request:
Don't re-run the selector after update
Fixes #1697

We can avoid running the selector twice by setting the latestStoreState at the same time as setting the latestSelectedState. If the store state hasn't changed, then the selector won't as well (since it's pure).

Patch:
diff --git a/src/hooks/useSelector.js b/src/hooks/useSelector.js
index 39066e7..87b61f2 100644
--- a/src/hooks/useSelector.js
+++ b/src/hooks/useSelector.js
@@ -64,13 +64,15 @@ function useSelectorWithStoreAndSubscription(
   useIsomorphicLayoutEffect(() => {
     function checkForUpdates() {
       try {
-        const newSelectedState = latestSelector.current(store.getState())
+        const newStoreState = store.getState()
+        const newSelectedState = latestSelector.current(newStoreState)
 
         if (equalityFn(newSelectedState, latestSelectedState.current)) {
           return
         }
 
         latestSelectedState.current = newSelectedState
+        latestStoreState.current = newStoreState
       } catch (err) {
         // we ignore all errors here, since when the component
         // is re-rendered, the selectors are called again, and


Test patch:
diff --git a/test/hooks/useSelector.spec.js b/test/hooks/useSelector.spec.js
index 3a0fcfd..0af0176 100644
--- a/test/hooks/useSelector.spec.js
+++ b/test/hooks/useSelector.spec.js
@@ -38,17 +38,21 @@ describe('React', () => {
         })
 
         it('selects the state and renders the component when the store updates', () => {
-          const { result } = renderHook(() => useSelector((s) => s.count), {
+          const selector = jest.fn((s) => s.count)
+
+          const { result } = renderHook(() => useSelector(selector), {
             wrapper: (props) => <ProviderMock {...props} store={store} />,
           })
 
           expect(result.current).toEqual(0)
+          expect(selector).toHaveBeenCalledTimes(2)
 
           act(() => {
             store.dispatch({ type: '' })
           })
 
           expect(result.current).toEqual(1)
+          expect(selector).toHaveBeenCalledTimes(3)
         })
       })
Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 342
Good morning! Here's your coding interview problem for today.

This problem was asked by Stripe.

`reduce` (also known as `fold`) is a function that takes in an array, a combining function, and an initial value and builds up a result by calling the combining function on each element of the array, left to right. For example, we can write `sum()` in terms of `reduce`:
```
def add(a, b):
    return a + b

def sum(lst):
    return reduce(lst, add, 0)
```
This should call `add` on the initial value with the first element of the array, and then the result of that with the second element of the array, and so on until we reach the end, when we return the sum of the array.

Implement your own version of `reduce`.

Pull request:
Day342
Resolves #682.

Patch:
diff --git a/README.md b/README.md
index 2ab56a5..3e2ccd9 100644
--- a/README.md
+++ b/README.md
@@ -332,3 +332,4 @@ problems from
 * [Day 338](https://github.com/vaskoz/dailycodingproblem-go/issues/675)
 * [Day 339](https://github.com/vaskoz/dailycodingproblem-go/issues/676)
 * [Day 340](https://github.com/vaskoz/dailycodingproblem-go/issues/679)
+* [Day 342](https://github.com/vaskoz/dailycodingproblem-go/issues/682)
diff --git a/day342/problem.go b/day342/problem.go
new file mode 100644
index 0000000..da1d5d5
--- /dev/null
+++ b/day342/problem.go
@@ -0,0 +1,14 @@
+package day342
+
+// Reduce is a function that takes in an array,
+// a combining function, and an initial value
+// and builds up a result by calling the combining
+// function on each element of the array, left to right.
+func Reduce(lst []interface{},
+	reducer func(a, b interface{}) interface{},
+	initial interface{}) interface{} {
+	for _, v := range lst {
+		initial = reducer(initial, v)
+	}
+	return initial
+}


Test patch:
diff --git a/day342/problem_test.go b/day342/problem_test.go
new file mode 100644
index 0000000..413f583
--- /dev/null
+++ b/day342/problem_test.go
@@ -0,0 +1,48 @@
+package day342
+
+import (
+	"fmt"
+	"testing"
+)
+
+// nolint
+var testcases = []struct {
+	lst      []interface{}
+	reducer  func(a, b interface{}) interface{}
+	initial  interface{}
+	expected interface{}
+}{
+	{
+		[]interface{}{1, 2, 3, 4, 5, 6},
+		func(a, b interface{}) interface{} {
+			return a.(int) + b.(int)
+		},
+		0,
+		21,
+	},
+	{
+		[]interface{}{"hello", "world", "goodbye"},
+		func(a, b interface{}) interface{} {
+			return fmt.Sprintf("%s %s", a, b)
+		},
+		"begin",
+		"begin hello world goodbye",
+	},
+}
+
+func TestReduce(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if result := Reduce(tc.lst, tc.reducer, tc.initial); result != tc.expected {
+			t.Errorf("Expected %v, got %v", tc.expected, result)
+		}
+	}
+}
+
+func BenchmarkReduce(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			Reduce(tc.lst, tc.reducer, tc.initial)
+		}
+	}
+}
Repository: spf13/viper (go)

Issue:
SetEnvKeyReplacer(): replace concrete type "strings.Replacer" with its interface
# Introduction
Current implementation of [SetEnvKeyReplacer](https://github.com/spf13/viper/blob/8e194e8ad2432506b0a6dac93dd7876fca7a94a5/viper.go#L1091) has parameter `r` with type of certain struct pointer: ***strings.Replacer**.
# Problem
The implementation doesn't allow us to use custom string-replacers. For example, we can't use **LowerCamelCase**-to-**ScreamingSnakeCase** replacer: `myParamter` -> `MY_PARAMETER`
# Solution
There's an internal interface in go's std-lib: [strings.replacer](https://golang.org/src/strings/replace.go). It is the good way to standardize all string-replacers.
If **SetEnvKeyReplacer()** accepts the interface, then we might use any implementation of it.
Could you change it, please?

Pull request:
Add string replacer interface and env key replacer option
Fixes #569
Fixes #575
Fixes #624

Patch:
diff --git a/README.md b/README.md
index b0392c9..327308b 100644
--- a/README.md
+++ b/README.md
@@ -263,6 +263,9 @@ keys to an extent. This is useful if you want to use `-` or something in your
 `Get()` calls, but want your environmental variables to use `_` delimiters. An
 example of using it can be found in `viper_test.go`.
 
+Alternatively, you can use `EnvKeyReplacer` with `NewWithOptions` factory function.
+Unlike `SetEnvKeyReplacer`, it accepts a `StringReplacer` interface allowing you to write custom string replacing logic.
+
 By default empty environment variables are considered unset and will fall back to
 the next configuration source. To treat empty environment variables as set, use
 the `AllowEmptyEnv` method.
diff --git a/viper.go b/viper.go
index 4e4d6da..19f15d8 100644
--- a/viper.go
+++ b/viper.go
@@ -197,7 +197,7 @@ type Viper struct {
 	envPrefix         string
 
 	automaticEnvApplied bool
-	envKeyReplacer      *strings.Replacer
+	envKeyReplacer      StringReplacer
 	allowEmptyEnv       bool
 
 	config         map[string]interface{}
@@ -257,6 +257,19 @@ func KeyDelimiter(d string) Option {
 	})
 }
 
+// StringReplacer applies a set of replacements to a string.
+type StringReplacer interface {
+	// Replace returns a copy of s with all replacements performed.
+	Replace(s string) string
+}
+
+// EnvKeyReplacer sets a replacer used for mapping environment variables to internal keys.
+func EnvKeyReplacer(r StringReplacer) Option {
+	return optionFunc(func(v *Viper) {
+		v.envKeyReplacer = r
+	})
+}
+
 // NewWithOptions creates a new Viper instance.
 func NewWithOptions(opts ...Option) *Viper {
 	v := New()


Test patch:
diff --git a/viper_test.go b/viper_test.go
index 9f4dff3..8f010c7 100644
--- a/viper_test.go
+++ b/viper_test.go
@@ -549,6 +549,15 @@ func TestSetEnvKeyReplacer(t *testing.T) {
 	assert.Equal(t, "30s", Get("refresh-interval"))
 }
 
+func TestEnvKeyReplacer(t *testing.T) {
+	v := NewWithOptions(EnvKeyReplacer(strings.NewReplacer("-", "_")))
+
+	v.AutomaticEnv()
+	_ = os.Setenv("REFRESH_INTERVAL", "30s")
+
+	assert.Equal(t, "30s", v.Get("refresh-interval"))
+}
+
 func TestAllKeys(t *testing.T) {
 	initConfigs()