nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: ocsigen/lwt
Pull request #891 (2021-10-05 19:09:15)

Restore ocaml-ci
ocaml-ci began to fail when https://github.com/ocurrent/ocaml-ci/pull/338 was merged, since `dune build @check` requires `ppx_let`.

For testing purposes, `ppx_let` only adds a test dependency on base, which (to me at least) doesn't seem to impose as heavy a dependency burden as suggested in https://github.com/ocsigen/lwt/issues/677.

This approach is far from the only possibility, but I add a dummy opam file whose purpose is to create a package context to house the dependency. This gets picked up by ocaml-ci and also by `opam install . --deps-only`


Patch:
diff --git a/lwt_ppx_let.opam b/lwt_ppx_let.opam
new file mode 100644
index 000000000..6b03c74f4
--- /dev/null
+++ b/lwt_ppx_let.opam
@@ -0,0 +1,27 @@
+opam-version: "2.0"
+
+synopsis: "Dummy package context for ppx_let tests"
+
+version: "5.4.2"
+license: "MIT"
+homepage: "https://github.com/ocsigen/lwt"
+doc: "https://ocsigen.org/lwt"
+bug-reports: "https://github.com/ocsigen/lwt/issues"
+
+authors: [
+  "Jérôme Vouillon"
+  "Jérémie Dimino"
+]
+maintainer: [
+  "Raphaël Proust <code@bnwr.net>"
+  "Anton Bachin <antonbachin@yahoo.com>"
+]
+dev-repo: "git+https://github.com/ocsigen/lwt.git"
+
+depends: [
+  "dune" {>= "1.8.0"}
+  "lwt"
+  "ppx_let" {with-test}
+]
+
+description: "Internal package used to partition ppx_let tests."


Test patch:
diff --git a/test/ppx_let/dune b/test/ppx_let/dune
index d6997740b..71b4e5c5b 100644
--- a/test/ppx_let/dune
+++ b/test/ppx_let/dune
@@ -2,3 +2,8 @@
  (name test)
  (preprocess (pps ppx_let))
  (libraries lwt lwt.unix))
+
+(alias
+ (name runtest)
+ (package lwt_ppx_let)
+ (action (run %{exe:test.exe})))
Repository: alibaba/hooks
Pull request #753 (2020-11-27 14:21:55)

fix useLockFn
 保证useLockFn的不变形，以免触发无意义的子组件渲染


Patch:
diff --git a/packages/hooks/src/useLockFn/index.ts b/packages/hooks/src/useLockFn/index.ts
index 42bd0520..5d37fc5c 100644
--- a/packages/hooks/src/useLockFn/index.ts
+++ b/packages/hooks/src/useLockFn/index.ts
@@ -1,20 +1,23 @@
-import { useRef } from 'react';
+import { useRef, useCallback } from 'react';
 
 function useLockFn<P extends any[] = any[], V extends any = any>(fn: (...args: P) => Promise<V>) {
   const lockRef = useRef(false);
 
-  return async function (...args: P) {
-    if (lockRef.current) return;
-    lockRef.current = true;
-    try {
-      const ret = await fn(...args);
-      lockRef.current = false;
-      return ret;
-    } catch (e) {
-      lockRef.current = false;
-      throw e;
-    }
-  };
+  return useCallback(
+    async function (...args: P) {
+      if (lockRef.current) return;
+      lockRef.current = true;
+      try {
+        const ret = await fn(...args);
+        lockRef.current = false;
+        return ret;
+      } catch (e) {
+        lockRef.current = false;
+        throw e;
+      }
+    },
+    [fn],
+  );
 }
 
 export default useLockFn;


Test patch:
diff --git a/packages/hooks/src/useLockFn/__tests__/index.test.ts b/packages/hooks/src/useLockFn/__tests__/index.test.ts
index f18fc12c..94d27570 100644
--- a/packages/hooks/src/useLockFn/__tests__/index.test.ts
+++ b/packages/hooks/src/useLockFn/__tests__/index.test.ts
@@ -1,5 +1,5 @@
 import { renderHook, act } from '@testing-library/react-hooks';
-import { useRef } from 'react';
+import { useRef, useCallback, useState } from 'react';
 import useLockFn from '../index';
 import { sleep } from '../../utils/testingHelpers';
 
@@ -10,15 +10,21 @@ describe('useLockFn', () => {
 
   const setUp = (): any =>
     renderHook(() => {
+      const [tag, updateTag] = useState(false);
       const countRef = useRef(0);
-      const locked = useLockFn(async (step: number) => {
-        countRef.current += step;
-        await sleep(50);
-      });
+      const persistFn = useCallback(
+        async (step: number) => {
+          countRef.current += step;
+          await sleep(50);
+        },
+        [tag],
+      );
+      const locked = useLockFn(persistFn);
 
       return {
         locked,
         countRef,
+        updateTag: () => updateTag(true),
       };
     });
 
@@ -38,4 +44,13 @@ describe('useLockFn', () => {
     locked(5);
     expect(countRef.current).toBe(5);
   });
+
+  it('should same', () => {
+    const hook = setUp();
+    const preLocked = hook.result.current.locked;
+    hook.rerender();
+    expect(hook.result.current.locked).toEqual(preLocked);
+    act(hook.result.current.updateTag);
+    expect(hook.result.current.locked).not.toEqual(preLocked);
+  });
 });
Repository: alibaba/hooks
Pull request #904 (2021-04-02 13:55:09)

fix(useReactive): 修复当使用 delete 操作符时页面不刷新
**demo**：

```jsx
const App = () => {
const obj =useReactive({ name: 'zhang', age: 10 })
const handleDeleteName = () => {
  delete obj.name
}
return <div>
  <div>name: {obj.name}</div>
  <button onClick={ () => handleDeleteName() }>删除 name</button>
</div>
}
```

**预期结果**：我们需要删除一个属性时，视图应该刷新

**实际结果**：并未发生变化

**解决方案**：使用  `deleteProperty`  拦截 `delete` 操作，具体情况 packages/hooks/src/useReactive/index.ts 38 行



Patch:
diff --git a/packages/hooks/src/useReactive/index.ts b/packages/hooks/src/useReactive/index.ts
index 5e05151f..30e3c899 100644
--- a/packages/hooks/src/useReactive/index.ts
+++ b/packages/hooks/src/useReactive/index.ts
@@ -35,6 +35,11 @@ function observer<T extends object>(initialVal: T, cb: () => void): T {
       cb();
       return ret;
     },
+    deleteProperty(target, key) {
+      const ret = Reflect.deleteProperty(target, key);
+      cb();
+      return ret;
+    },
   });
 
   proxyMap.set(initialVal, proxy);


Test patch:
diff --git a/packages/hooks/src/useReactive/__tests__/index.test.tsx b/packages/hooks/src/useReactive/__tests__/index.test.tsx
index f005334f..b2e3f838 100644
--- a/packages/hooks/src/useReactive/__tests__/index.test.tsx
+++ b/packages/hooks/src/useReactive/__tests__/index.test.tsx
@@ -12,6 +12,7 @@ const Demo = () => {
       },
     },
     arr: [1],
+    foo: 'foo',
   });
 
   return (
@@ -19,10 +20,16 @@ const Demo = () => {
       <p>
         counter state.count：<span role="addCount">{state.count}</span>
       </p>
+      <p>
+        delete property：<span role="deleteProperty">{state.foo}</span>
+      </p>
 
       <button role="addCountBtn" onClick={() => (state.count += 1)}>
         state.count++
       </button>
+      <button role="deletePropertyBtn" onClick={() => delete state.foo}>
+        delete state.foo
+      </button>
       <button role="subCountBtn" style={{ marginLeft: '50px' }} onClick={() => (state.count -= 1)}>
         state.count--
       </button>
@@ -143,4 +150,17 @@ describe('test useReactive feature', () => {
     });
     expect(inputVal.textContent).toBe('bbb');
   });
+
+  it('delete object property', () => {
+    let wrap = render(<Demo />);
+
+    let deleteProperty = wrap.getByRole('deleteProperty');
+    let deletePropertyBtn = wrap.getByRole('deletePropertyBtn');
+    expect(deleteProperty.textContent).toBe('foo');
+
+    act(() => {
+      fireEvent.click(deletePropertyBtn);
+    });
+    expect(deleteProperty.textContent).toBe('');
+  });
 });
Repository: leifg/formulon
Pull request #1242 (2025-05-09 23:31:25)

fix: guard against date parsing errors


Patch:
diff --git a/src/functions.js b/src/functions.js
index e0a2fef..d55d506 100644
--- a/src/functions.js
+++ b/src/functions.js
@@ -67,13 +67,25 @@ export const sf$date = (year, month, day) => (
   buildDateLiteral(year.value, month.value, day.value)
 );
 
-export const sf$datevalue = (expression) => (
-  buildDateLiteral(new Date(Date.parse(expression.value)))
-);
+export const sf$datevalue = (expression) => {
+  const parsedDate = Date.parse(expression.value);
 
-export const sf$datetimevalue = (expression) => (
-  buildDatetimeLiteral(Date.parse(`${expression.value}Z`))
-);
+  if(isNaN(parsedDate)) {
+    throw new ArgumentError(`Invalid Value '${expression.value}' for 'DATEVALUE()'.`, { function: 'datevalue', input: expression.value });
+  }
+
+  return buildDateLiteral(new Date(parsedDate));
+};
+
+export const sf$datetimevalue = (expression) => {
+  const parsedDate = Date.parse(`${expression.value}Z`)
+
+  if(isNaN(parsedDate)) {
+    throw new ArgumentError(`Invalid Value '${expression.value}' for 'DATETIMEVALUE()'.`, { function: 'datetimevalue', input: expression.value });
+  }
+
+  return buildDatetimeLiteral(parsedDate);
+};
 
 export const sf$day = (date) => (
   buildLiteralFromJs(date.value.getUTCDate())


Test patch:
diff --git a/test/unit/functions.spec.js b/test/unit/functions.spec.js
index 526d07e..7716aed 100644
--- a/test/unit/functions.spec.js
+++ b/test/unit/functions.spec.js
@@ -38,6 +38,12 @@ describe('datetimevalue', () => {
     const expected = buildDatetimeLiteral(Date.UTC(2020, 1, 11, 17, 39, 0, 973));
     expect(dispatch('datetimevalue', [input])).to.deep.eq(expected);
   });
+
+  it('returns argument error for invalid date time', () => {
+    const input = buildLiteralFromJs('Some time in February');
+    const expected = buildErrorLiteral('ArgumentError', "Invalid Value 'Some time in February' for 'DATETIMEVALUE()'.", { function: 'datetimevalue', input: 'Some time in February' });
+    expect(dispatch('datetimevalue', [input])).to.deep.eq(expected);
+  });
 });
 
 describe('datevalue', () => {
@@ -45,6 +51,12 @@ describe('datevalue', () => {
     const expected = buildDateLiteral(2020, 2, 11);
     expect(dispatch('datevalue', [buildLiteralFromJs('2020-02-11')])).to.deep.eq(expected);
   });
+
+  it('returns argument error for invalid date', () => {
+    const input = buildLiteralFromJs('Some day in February');
+    const expected = buildErrorLiteral('ArgumentError', "Invalid Value 'Some day in February' for 'DATEVALUE()'.", { function: 'datevalue', input: 'Some day in February' });
+    expect(dispatch('datevalue', [input])).to.deep.eq(expected);
+  });
 });
 
 describe('day', () => {