PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 343
Good morning! Here's your coding interview problem for today.

This problem was asked by Google.

Given a binary search tree and a range `[a, b]` (inclusive), return the sum of the elements of the binary search tree within the range.

For example, given the following tree:
```
    5
   / \
  3   8
 / \ / \
2  4 6  10
```
and the range `[4, 9]`, return `23` `(5 + 4 + 6 + 8)`.

Pull request:
Day343
Resolves #685.

Patch:
diff --git a/README.md b/README.md
index 75a020e..a473b19 100644
--- a/README.md
+++ b/README.md
@@ -333,6 +333,7 @@ problems from
 * [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)
+* [Day 343](https://github.com/vaskoz/dailycodingproblem-go/issues/685)
 * [Day 345](https://github.com/vaskoz/dailycodingproblem-go/issues/687)
 * [Day 346](https://github.com/vaskoz/dailycodingproblem-go/issues/688)
 * [Day 347](https://github.com/vaskoz/dailycodingproblem-go/issues/689)
diff --git a/day343/problem.go b/day343/problem.go
new file mode 100644
index 0000000..3c1be59
--- /dev/null
+++ b/day343/problem.go
@@ -0,0 +1,22 @@
+package day343
+
+// BST is an integer binary search tree.
+type BST struct {
+	Val         int
+	Left, Right *BST
+}
+
+// SumBSTRange takes a BST root node and
+// two values indicating a range.
+// Runs in linear time recursively.
+func SumBSTRange(root *BST, a, b int) int {
+	if root == nil || a > b {
+		return 0
+	}
+	leftSum := SumBSTRange(root.Left, a, root.Val)
+	rightSum := SumBSTRange(root.Right, root.Val, b)
+	if root.Val >= a && root.Val <= b {
+		return root.Val + leftSum + rightSum
+	}
+	return leftSum + rightSum
+}


Test patch:
diff --git a/day343/problem_test.go b/day343/problem_test.go
new file mode 100644
index 0000000..94f68a1
--- /dev/null
+++ b/day343/problem_test.go
@@ -0,0 +1,62 @@
+package day343
+
+import "testing"
+
+// nolint
+var testcases = []struct {
+	root     *BST
+	a, b     int
+	expected int
+}{
+	{
+		&BST{
+			5,
+			&BST{
+				3,
+				&BST{2, nil, nil},
+				&BST{4, nil, nil},
+			},
+			&BST{
+				8,
+				&BST{6, nil, nil},
+				&BST{10, nil, nil},
+			},
+		},
+		4, 9,
+		23,
+	},
+	{
+		&BST{
+			5,
+			&BST{
+				3,
+				&BST{2, nil, nil},
+				&BST{4, nil, nil},
+			},
+			&BST{
+				8,
+				&BST{6, nil, nil},
+				&BST{10, nil, nil},
+			},
+		},
+		9, 4,
+		0,
+	},
+}
+
+func TestSumBSTRange(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if sum := SumBSTRange(tc.root, tc.a, tc.b); sum != tc.expected {
+			t.Errorf("Expected %v, got %v", tc.expected, sum)
+		}
+	}
+}
+
+func BenchmarkSumBSTRange(b *testing.B) {
+	for i := 0; i < b.N; i++ {
+		for _, tc := range testcases {
+			SumBSTRange(tc.root, tc.a, tc.b)
+		}
+	}
+}
Repository: tox-dev/sphinx-autodoc-typehints (python)

Issue:
Conflict with directives `seealso`, `deprecated`, ...

Minimal reproduction example:

```python

def hello() -> str:
    """
    .. seealso:: more info at <https://example.com>`_.
    """
    return "Hello, world!"
```

This triggers this warning during build:

> .../helloworld.py:docstring of helloworld.hello:3: WARNING: Explicit markup ends without a blank line; unexpected unindent.

(using sphinx==7.4.1, sphinx_autodoc_typehints==2.2.2)


Pull request:
Fix rendering when docstring starst with a directive
We want to position our insertion before the directive but we incorrectly get a negative insertion line. This inserts at the end rather than at the beginning, and we fail to leave the correct empty line after the directive.

Resolves #467

Patch:
diff --git a/src/sphinx_autodoc_typehints/__init__.py b/src/sphinx_autodoc_typehints/__init__.py
index 6002019..824f458 100644
--- a/src/sphinx_autodoc_typehints/__init__.py
+++ b/src/sphinx_autodoc_typehints/__init__.py
@@ -849,7 +849,7 @@ def get_insert_index(app: Sphinx, lines: list[str]) -> InsertIndexInfo | None:
         # at end. (I don't know of any input where this happens.)
         next_sibling = child.next_node(descend=False, siblings=True)
         line_no = node_line_no(next_sibling) if next_sibling else None
-        at = line_no - 2 if line_no else len(lines)
+        at = max(line_no - 2, 0) if line_no else len(lines)
         return InsertIndexInfo(insert_index=at, found_param=True)
 
     # 4. Insert before examples
@@ -857,7 +857,7 @@ def get_insert_index(app: Sphinx, lines: list[str]) -> InsertIndexInfo | None:
         if tag_name(child) in {"literal_block", "paragraph", "field_list"}:
             continue
         line_no = node_line_no(child)
-        at = line_no - 2 if line_no else len(lines)
+        at = max(line_no - 2, 0) if line_no else len(lines)
         return InsertIndexInfo(insert_index=at, found_directive=True)
 
     # 5. Otherwise, insert at end


Test patch:
diff --git a/tests/test_integration.py b/tests/test_integration.py
index 8d732d9..a9aec4c 100644
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -1342,6 +1342,24 @@ def docstring_with_multiline_note_after_params_epilog_replace(param: int) -> Non
     """
 
 
+@expected(
+    """
+    mod.docstring_with_see_also()
+
+       Return type:
+          "str"
+
+       See also: more info at <https://example.com>`_.
+
+    """
+)
+def docstring_with_see_also() -> str:
+    """
+    .. seealso:: more info at <https://example.com>`_.
+    """
+    return ""
+
+
 # Config settings for each test run.
 # Config Name: Sphinx Options as Dict.
 configs = {
Repository: tweag/nickel (rust)

Issue:
`default` values and contracts don’t compose properly
**Describe the bug**

When a value `bar` has a contract and a default value, and its default value itself has both a contract and a default value, then the default of the default value will be ignored, and only its contract will be applied.

**To Reproduce**

Evaluating

```
let
  myContract = { x | Str }
in
{
  foo | #myContract | default = { x = "From foo" },
  bar | #{..} | default = foo
}
```

results in

```
error: empty metavalue
  ┌─ /tmp/tmp.eYEzU3ur1v/test.ncl:4:18
  │
4 │   myContract = { x | Str }
  │                  ^^^^^^^ here
```

rather than the expected

```
{
  "bar": {
    "x": "From foo"
  },
  "foo": {
    "x": "From foo"
  }
}
```

Everything works fine if `bar` either doesn’t have a contract or has a plain type annotation (`bar | { x : Str } | default = foo`).


**Environment**
 - OS name + version: NixOS 21.05
 - Version of the code: 8ce9a90

/cc @yannham 

Pull request:
[Fix]Make MergeContract operator strict in its arguments
Fix #402.

When using merge for the application of a record contract, we should ignore top-level meta-data such as a default priority which can otherwise cause inner default values of the tested value to be silently dropped (see #402 for an example). That is, when merge is used for a contract-as-a-record application, it must be strict in its arguments with respect to metavalues.

Patch:
diff --git a/src/term.rs b/src/term.rs
index da56fdb6..8063bc62 100644
--- a/src/term.rs
+++ b/src/term.rs
@@ -810,7 +810,6 @@ impl NAryOp {
 
     pub fn is_strict(&self) -> bool {
         match self {
-            NAryOp::MergeContract() => false,
             _ => true,
         }
     }


Test patch:
diff --git a/tests/pass/contracts.ncl b/tests/pass/contracts.ncl
index 0e89ebbc..e3730e04 100644
--- a/tests/pass/contracts.ncl
+++ b/tests/pass/contracts.ncl
@@ -100,4 +100,12 @@ f `boo == 3) &&
 (({foo : {bar: Bool} | default = {bar = false}} & {foo.bar = true}).foo.bar
   | #Assert) &&
 
+// nested_metavalues
+// Regression test for #402
+(let myContract = { x | Str } in
+{
+  foo | #myContract | default = { x = "From foo" },
+  bar | #{..} | default = foo
+} == { foo.x = "From foo", bar.x = "From foo"} | #Assert) &&
+
 true
Repository: vuejs/vue-next (ts)

Issue:
errorHandler doesn't catch errors from onActivated when callback is async
### Version
3.2.22

### Reproduction link
[codesandbox.io](https://codesandbox.io/s/dazzling-hodgkin-3z9o8)







### Steps to reproduce
Add an errorhandler to app.config.errorHandler.
Then add onActivated with async function to the setup() function of a component and throw an error inside.

### What is expected?
The errorHandler added to app.config.errorHandler should catch the error (like it does for onMounted)

### What is actually happening?
app.config.errorHandler does not catch the error

---
I've tried async with onMounted, which works perfectly fine.
I'm using onActivated with keep-alive

<!-- generated by vue-issues. DO NOT REMOVE -->

Pull request:
fix(runtime-core): return hook() in wrappedHook to handle the async call in KeepAliveHook.
fix #4976 

Patch:
diff --git a/packages/runtime-core/src/components/KeepAlive.ts b/packages/runtime-core/src/components/KeepAlive.ts
index 30ad4400d..223a7c602 100644
--- a/packages/runtime-core/src/components/KeepAlive.ts
+++ b/packages/runtime-core/src/components/KeepAlive.ts
@@ -381,7 +381,7 @@ function registerKeepAliveHook(
         }
         current = current.parent
       }
-      hook()
+      return hook()
     })
   injectHook(type, wrappedHook, target)
   // In addition to registering it on the target instance, we walk up the parent


Test patch:
diff --git a/packages/runtime-core/__tests__/components/KeepAlive.spec.ts b/packages/runtime-core/__tests__/components/KeepAlive.spec.ts
index 4dce5d144..b60931e1f 100644
--- a/packages/runtime-core/__tests__/components/KeepAlive.spec.ts
+++ b/packages/runtime-core/__tests__/components/KeepAlive.spec.ts
@@ -16,7 +16,9 @@ import {
   cloneVNode,
   provide,
   defineAsyncComponent,
-  Component
+  Component,
+  createApp,
+  onActivated
 } from '@vue/runtime-test'
 import { KeepAliveProps } from '../../src/components/KeepAlive'
 
@@ -874,4 +876,31 @@ describe('KeepAlive', () => {
     await nextTick()
     expect(serializeInner(root)).toBe('<p>1</p>')
   })
+
+  // #4976
+  test('handle error in async onActivated', async () => {
+    const err = new Error('foo')
+    const handler = jest.fn()
+
+    const app = createApp({
+      setup() {
+        return () => h(KeepAlive, null, () => h(Child))
+      }
+    })
+
+    const Child = {
+      setup() {
+        onActivated(async () => {
+          throw err
+        })
+      },
+      render() {}
+    }
+
+    app.config.errorHandler = handler
+    app.mount(nodeOps.createElement('div'))
+
+    await nextTick()
+    expect(handler).toHaveBeenCalledWith(err, {}, 'activated hook')
+  })
 })
Repository: ktsn/vuex-smart-module (ts)

Issue:
Can't access subModules actions or mutations of a SubModule from context(store).modules
Hey, thanks for your last release allowing subModules access with symbols!

But there is a bug, we can't access actions or mutations of submodules with the `context(store).modules.nameOfModule` feature.
The only way to access it, is, with the `option.modules!.nameOfModule.context(store)` way.

![subModulesInMountedHook](https://user-images.githubusercontent.com/37144206/85847825-6aa7ec00-b7a8-11ea-894b-8bd173f006ad.png)

Here are the log of this mounted hook: 
![logOfSubModulesActions](https://user-images.githubusercontent.com/37144206/85847833-6c71af80-b7a8-11ea-9325-8b1ceccb7810.png)

As we can see the first way doesn't show anything when we try to show the actions of a submodules,  it's the same for `actions` and `mutations`. (getters and state are shown)

BTW: On the readme, there is only the first way specified.


Pull request:
fix: allow to use `actions` and `mutations` of nested contexts
fix #242 

Patch:
diff --git a/src/context.ts b/src/context.ts
index 228a7bd..4c7cc0d 100644
--- a/src/context.ts
+++ b/src/context.ts
@@ -250,7 +250,8 @@ export class Context<Mod extends Module<any, any, any, any, any>> {
 
   get modules(): ModulesContexts<Mod> {
     const modules = {} as ModulesContexts<Mod>
-    const children = this.moduleOptions.modules
+    const children: Record<string, Module<any, any, any, any, any>> = this
+      .moduleOptions.modules
     if (!children) {
       return modules
     }
@@ -262,7 +263,7 @@ export class Context<Mod extends Module<any, any, any, any, any>> {
           return new Context(
             createLazyContextPosition(child),
             this.store,
-            child
+            child.options
           )
         },
       })


Test patch:
diff --git a/test/nested.spec.ts b/test/nested.spec.ts
index 359f78e..b7dbc00 100644
--- a/test/nested.spec.ts
+++ b/test/nested.spec.ts
@@ -60,4 +60,27 @@ describe('Nested modules', () => {
     expect(fooCtx.state.value).toBe(4)
     expect(fooCtx.getters.double).toBe(8)
   })
+
+  it("allows to access to nested module's actions and mutations", () => {
+    const root = new Module({
+      modules: {
+        foo,
+      },
+    })
+
+    const store = createStore(root)
+    const ctx = root.context(store)
+    const fooCtx = ctx.modules.foo
+
+    expect(fooCtx.state.value).toBe(1)
+    expect(fooCtx.getters.double).toBe(2)
+
+    fooCtx.mutations.inc(1)
+    expect(fooCtx.state.value).toBe(2)
+    expect(fooCtx.getters.double).toBe(4)
+
+    fooCtx.actions.inc(2)
+    expect(fooCtx.state.value).toBe(4)
+    expect(fooCtx.getters.double).toBe(8)
+  })
 })
Repository: zh-lx/pinyin-pro (ts)

Issue:
polyphonic: 非中文字符表现与 pinyin api 不一致
## bug 描述

`polyphonic` 非中文字符返回结果为空，`pinyin` 会返回原字符

## 你预期的样子是？

`polyphonic` 非中文字符返回原字符

## pinyin-pro 版本号

`3.20.0`


Pull request:
fix: 修复 polyphonic 对非中文字符的处理
close #225 

Patch:
diff --git a/lib/core/polyphonic/index.ts b/lib/core/polyphonic/index.ts
index d417ea3..70e6ef5 100644
--- a/lib/core/polyphonic/index.ts
+++ b/lib/core/polyphonic/index.ts
@@ -209,11 +209,11 @@ const getPolyphonicList = (text: string): SingleWordResult[] => {
   return text.split('').map((word) => {
     const wordCode = word.charCodeAt(0);
     const customPolyphonicDict = getCustomPolyphonicDict();
-    const pinyin = customPolyphonicDict[wordCode] || DICT1[wordCode] || '';
+    const pinyin = customPolyphonicDict[wordCode] || DICT1[wordCode] || word;
     return {
       origin: word,
       result: pinyin,
-      isZh: !!pinyin,
+      isZh: pinyin !== word,
       originPinyin: pinyin,
     };
   });


Test patch:
diff --git a/test/polyphonic.test.js b/test/polyphonic.test.js
index 0ce2b1c..114587a 100644
--- a/test/polyphonic.test.js
+++ b/test/polyphonic.test.js
@@ -122,7 +122,7 @@ describe('polyphonic', () => {
 
   it('[polyphonic]nonzh', () => {
     const result = polyphonic('好好学习s');
-    expect(result).to.deep.equal(['hǎo hào', 'hǎo hào', 'xué', 'xí', '']);
+    expect(result).to.deep.equal(['hǎo hào', 'hǎo hào', 'xué', 'xí', 's']);
   });
 
   it('[polyphonic]all&nonZh', () => {