PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: sveltejs/prettier-plugin-svelte (ts)
Issue: Comments get removed from formated Svelte Component
Hi when I format a svelte component, any comment that is at the end of an element gets removed.

Gets removed:
```
<div>
    <div/>
    <!-- testing 123 -->
</div>
```

Doesn't get removed:
```
<div>
    <!-- testing 123 -->
    <div/>
</div>
```

Any solutions?
Pull request description: (fix) embed check
When checking if an embed starts after a node, return early if that node is not at the top level of html, because embeds cannot start after it.
Fixes #207

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ef4a502..7e8b07f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # prettier-plugin-svelte changelog
 
+## 2.1.6 (Unreleased)
+
+* Fix wrong removal of comment ([#207](https://github.com/sveltejs/prettier-plugin-svelte/issues/207))
+
 ## 2.1.5
 
 * Fix retrieval of comment belonging to `<script>`/`<style>` block ([#205](https://github.com/sveltejs/prettier-plugin-svelte/issues/205))
diff --git a/src/print/node-helpers.ts b/src/print/node-helpers.ts
index f040456..8c8aa7e 100644
--- a/src/print/node-helpers.ts
+++ b/src/print/node-helpers.ts
@@ -128,6 +128,12 @@ export function getLeadingComment(path: FastPath): CommentNode | undefined {
 export function doesEmbedStartAfterNode(node: Node, path: FastPath, siblings = getSiblings(path)) {
     const position = node.end;
     const root = path.stack[0];
+    // If node is not at the top level of html, an embed cannot start after it,
+    // because embeds are only at the top level
+    if (!root.html || !root.html.children || !root.html.children.includes(node)) {
+        return false;
+    }
+
     const embeds = [root.css, root.html, root.instance, root.js, root.module] as Node[];
 
     const nextNode = siblings[siblings.indexOf(node) + 1];


Test patch:
diff --git a/test/printer/samples/comment-at-end.html b/test/printer/samples/comment-at-end.html
new file mode 100644
index 0000000..cceefa9
--- /dev/null
+++ b/test/printer/samples/comment-at-end.html
@@ -0,0 +1,6 @@
+<div>
+    <div />
+    <!-- testing 123 -->
+</div>
+
+<style></style>
Repository: gcanti/tcomb (js)
Issue: strict Struct with additional methods throws a TypeError on updating
Test case:

```javascript
const t = require('tcomb');

const Rectangle = t.struct({
  width: t.Number,
  height: t.Number
}, {strict: true});

Rectangle.prototype.getArea = function () {
  return this.width * this.height;
};

let r = Rectangle({width: 10, height: 10});
Rectangle.update(r, {width: {$set: 20}});
```
throws:
```
TypeError: [tcomb] Invalid additional prop "getArea" supplied to Struct{width: Number, height: Number}
```

replacing `lib/assign.js` with `Object.assign` seems to fix the problem.
Pull request description: strict structs with additional methods should not throw on updating, …
…fix #267

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7478e1f..a6dfda2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,11 @@
 **Note**: Gaps between patch versions are faulty/broken releases.
 **Note**: A feature tagged as Experimental is in a high state of flux, you're at risk of it changing without notice.
 
+# v3.2.16
+
+- **Bug Fix**
+  - strict structs with additional methods should not throw on updating, fix #267 (@gcanti)
+
 # v3.2.15
 
 - **New Feature**
diff --git a/lib/assign.js b/lib/assign.js
index cfef6ca..156a78b 100644
--- a/lib/assign.js
+++ b/lib/assign.js
@@ -1,8 +1,10 @@
 function assign(x, y) {
   for (var k in y) {
-    x[k] = y[k];
+    if (y.hasOwnProperty(k)) {
+      x[k] = y[k];
+    }
   }
   return x;
 }
 
-module.exports = assign;
\ No newline at end of file
+module.exports = assign;
diff --git a/package.json b/package.json
index 54abb2d..f7720ef 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "tcomb",
-  "version": "3.2.15",
+  "version": "3.2.16",
   "description": "Type checking and DDD for JavaScript",
   "main": "index.js",
   "typings": "index.d.ts",


Test patch:
diff --git a/test/update.js b/test/update.js
index e500294..021ebf6 100644
--- a/test/update.js
+++ b/test/update.js
@@ -14,6 +14,20 @@ describe('t.update(instance, patch)', function () {
     y: t.Number
   });
 
+  it('strict structs with additional methods should not throw on updating', function () {
+    var Rectangle = t.struct({
+      width: t.Number,
+      height: t.Number
+    }, {strict: true});
+
+    Rectangle.prototype.getArea = function () {
+      return this.width * this.height;
+    };
+
+    var r = Rectangle({width: 10, height: 10});
+    assert.equal(Rectangle.update(r, {width: {$set: 20}}).width, 20);
+  });
+
   it('should throw if patch is invalid', function () {
     throwsWithMessage(function () {
       t.update({});
Repository: kiwicom/mobile (js)
Issue: Improve translation component
Now if translation is passed a null or undefined value in passThrough prop, it will display the string null or the string undefined. It should rather return null than the string null. 
Pull request description: Localization: have translation render null instead of string null when passThrough is undefined
closes #1311 

Patch:
diff --git a/packages/localization/src/Translation.js b/packages/localization/src/Translation.js
index ee889510..2605b183 100644
--- a/packages/localization/src/Translation.js
+++ b/packages/localization/src/Translation.js
@@ -71,6 +71,9 @@ export default class Translation extends React.Component<Props> {
     if (this.props.id === undefined) {
       // ID prop is missing so let's assume it's "pass through" translation
       // (property passThrough may be undefined)
+      if (this.props.passThrough == null) {
+        return null;
+      }
       return (
         <Text style={containerStyle}>
           {/* $FlowExpectedError: we do not allow to use 'string' in the 'Text' components but translations are exceptions. */}


Test patch:
diff --git a/packages/localization/src/__tests__/__snapshots__/Translation.test.js.snap b/packages/localization/src/__tests__/__snapshots__/Translation.test.js.snap
index c464a2b2..40c5e4df 100644
--- a/packages/localization/src/__tests__/__snapshots__/Translation.test.js.snap
+++ b/packages/localization/src/__tests__/__snapshots__/Translation.test.js.snap
@@ -1,10 +1,6 @@
 // Jest Snapshot v1, https://goo.gl/fbAQLP
 
-exports[`works with optional pass through parameter 1`] = `
-<Text>
-  undefined
-</Text>
-`;
+exports[`works with optional pass through parameter 1`] = `null`;
 
 exports[`works with pass through translations 1`] = `
 <Text>
Repository: DevExpress/devextreme-vue (ts)
Issue: dxDataGrid: Uncaught TypeError: Cannot read property 'beforeDestroy' of undefined
### Issue Type

[x] 'bug report'

### Description

#### Current Behavior

If you start up the examples (npm run serve), ungroup the region column in the dxDataGrid Example you'll get the following javascript error:

Uncaught TypeError: Cannot read property 'beforeDestroy' of undefined
    at callHook (vue.esm.js:2917)
    at HTMLDivElement.Vue.$destroy (vue.esm.js:2700)
    at HTMLDivElement.oneTimeHandler (events_engine.js:372)
    at callHandler (events_engine.js:117)
    at Object.wrappedHandler (events_engine.js:140)
    at handleCallback (events_engine.js:211)
    at Array.forEach (<anonymous>)
    at Object.callHandlers (events_engine.js:215)
    at events_engine.js:413
    at Object.<anonymous> (events_engine.js:281)

#### Expected Behavior

No error

### Steps to Reproduce

- npm run serve
- navigate to dxDataGrid example
- ungroup column region

(or click on page 2 - same error)

### Environment Details

- master as of 036025c9aa5129c34cc4f446bdbc89d8e6a34ede
- chrome 65.0.3325.181

Pull request description: Fix template vue instance disposing
Fixes #53.

Patch:
diff --git a/src/core/component.ts b/src/core/component.ts
index b32b018..cc9822c 100644
--- a/src/core/component.ts
+++ b/src/core/component.ts
@@ -67,7 +67,7 @@ const DxComponent: VueConstructor = Vue.extend({
                     const container = data.container.get ? data.container.get(0) : data.container;
                     container.appendChild(element);
 
-                    events.one(element, DX_REMOVE_EVENT, vm.$destroy);
+                    events.one(element, DX_REMOVE_EVENT, vm.$destroy.bind(vm));
 
                     return element;
                 }


Test patch:
diff --git a/src/core/component.test.ts b/src/core/component.test.ts
index cd14f7f..e61d4ef 100644
--- a/src/core/component.test.ts
+++ b/src/core/component.test.ts
@@ -180,6 +180,21 @@ describe("template", () => {
         expect(renderedTemplate.attributes).toHaveProperty("custom-attr");
         expect(renderedTemplate.attributes["custom-attr"].value).toBe("123");
     });
+
+    it("doesn't throw on dxremove", () => {
+        new Vue({
+            template: `<test-component>
+                            <div slot='item' slot-scope='props'>Template {{props.text}}</div>
+                        </test-component>`,
+            components: {
+                TestComponent
+            }
+        }).$mount();
+
+        const renderedTemplate = renderItemTemplate({ text: "with data" });
+
+        expect(() => events.triggerHandler(renderedTemplate, "dxremove")).not.toThrow();
+    });
 });
 
 describe("events emitting", () => {
Repository: keathley/norm (elixir)
Issue: Specifying that a value in a map or struct can be nil
It doesn't seem to be possible to specify that a value in map or struct can also be `nil`:

```elixir
conform(%{foo: nil}, schema(%{foo: spec(is_binary() or is_nil())}))
# => {:error, ["val: %{foo: nil} in: :foo fails: :required"]}
```

Am I missing something or is this a bug? 

Pull request description: Allow schema's to specify a value is nil.
Closes #17 

Patch:
diff --git a/lib/norm/schema.ex b/lib/norm/schema.ex
index 98386eb..b7b2e44 100644
--- a/lib/norm/schema.ex
+++ b/lib/norm/schema.ex
@@ -90,12 +90,13 @@ defmodule Norm.Schema do
     end
 
     defp check_spec({key, spec}, input, path) do
-      val = Map.get(input, key)
+      case Map.has_key?(input, key) do
+        false ->
+          {key, {:error, [error(path ++ [key], input, ":required")]}}
 
-      if val == nil do
-        {key, {:error, [error(path ++ [key], input, ":required")]}}
-      else
-        {key, Conformable.conform(spec, val, path ++ [key])}
+        true ->
+          val = Map.get(input, key)
+          {key, Conformable.conform(spec, val, path ++ [key])}
       end
     end
 


Test patch:
diff --git a/test/norm/schema_test.exs b/test/norm/schema_test.exs
index bc0df4a..ee4163a 100644
--- a/test/norm/schema_test.exs
+++ b/test/norm/schema_test.exs
@@ -58,6 +58,14 @@ defmodule Norm.SchemaTest do
     assert %{bool: false} == conform!(%{bool: false}, s)
   end
 
+  test "allows keys to have nil values" do
+    s = schema(%{foo: spec(is_nil())})
+
+    assert %{foo: nil} == conform!(%{foo: nil}, s)
+    assert {:error, errors} = conform(%{foo: 123}, s)
+    assert errors == ["val: 123 in: :foo fails: is_nil()"]
+  end
+
   describe "generation" do
     test "works with maps" do
       s =
Repository: MoOx/phenomic (js)
Issue: Extra closing parenthesis in aphrodite init code
In `phenomic/lib/components/Html/index.js`, there is this code to initialize `aphrodite`:

`script: [{ "innerHTML": "window._aphrodite = " + JSON.stringify(aproditeResult.css.renderedClassNames) + ");" }]`

There is an extra closing parenthesis but the opening one is missing. 

So, in production, I have a SyntaxError: `Uncaught SyntaxError: Unexpected token )`
Pull request description: Fix Aphrodite init
fix #922

Patch:
diff --git a/src/components/Html/index.js b/src/components/Html/index.js
index 160ff14c..d3d9bf5a 100644
--- a/src/components/Html/index.js
+++ b/src/components/Html/index.js
@@ -68,7 +68,7 @@ const Html = (props: Props) => {
         script={ [
           { "innerHTML": `window._aphrodite = ${
             JSON.stringify(aproditeResult.css.renderedClassNames)
-          });` },
+          };` },
         ] }
       />
     )


Test patch:
diff --git a/src/components/Html/__tests__/__snapshots__/aphrodite.js.snap b/src/components/Html/__tests__/__snapshots__/aphrodite.js.snap
index 003fc67c..e38ba7c1 100644
--- a/src/components/Html/__tests__/__snapshots__/aphrodite.js.snap
+++ b/src/components/Html/__tests__/__snapshots__/aphrodite.js.snap
@@ -26,7 +26,7 @@ exports[`test should render Html component with aphrodite styles when possible 1
     <script
       dangerouslySetInnerHTML={
         Object {
-          "__html": "window._aphrodite = [\"stuff\"]);",
+          "__html": "window._aphrodite = [\"stuff\"];",
         }
       }
       data-react-helmet={true} />
Repository: koajs/koa (js)
Issue: this.subdomains is error parsed
when host is 127.0.0.1 this.subdomains=> [127,0,0]
Pull request description: fix: subdomains should be [] if the host is an ip
Fixes #775

Patch:
diff --git a/lib/request.js b/lib/request.js
index c4a5ccf..830b21b 100644
--- a/lib/request.js
+++ b/lib/request.js
@@ -5,6 +5,7 @@
  * Module dependencies.
  */
 
+var net = require('net');
 var contentType = require('content-type');
 var stringify = require('url').format;
 var parse = require('parseurl');
@@ -417,7 +418,9 @@ module.exports = {
 
   get subdomains() {
     var offset = this.app.subdomainOffset;
-    return (this.host || '')
+    var host = this.host || '';
+    if (net.isIP(host)) return [];
+    return host
       .split('.')
       .reverse()
       .slice(offset);


Test patch:
diff --git a/test/request/subdomains.js b/test/request/subdomains.js
index 8df5be5..39b4b6b 100644
--- a/test/request/subdomains.js
+++ b/test/request/subdomains.js
@@ -14,8 +14,14 @@ describe('req.subdomains', function(){
     req.subdomains.should.eql(['tobi']);
   })
 
-  describe('with no host present', function(){
+  it('should work with no host present', function(){
     var req = request();
     req.subdomains.should.eql([]);
   })
+
+  it('should check if the host is an ip address', function(){
+    var req = request();
+    req.header.host = '127.0.0.1';
+    req.subdomains.should.eql([]);
+  });
 })
Repository: FontoXML/fontoxpath (ts)
Issue: Exceptions no longer stringify
In past versions of fontoxpath, exceptions would stringify to the error message. This seems no longer to be the case; they just give the dreaded `[object Object]`.

I can recover the error message by printing `error.h` (in version 3.30.2), but that's fragile and depends on the minification of the exception object.
Pull request description: Print and rethrow errors thrown during parsing in registerXQueryModule
This fixes parse errors in this API throwing out the raw StackTraceEntry object, which is not a proper error.

Fixes #628

Patch:
diff --git a/src/registerXQueryModule.ts b/src/registerXQueryModule.ts
index 25004bba..d0c7055b 100644
--- a/src/registerXQueryModule.ts
+++ b/src/registerXQueryModule.ts
@@ -49,10 +49,15 @@ export default function registerXQueryModule(
 	moduleString: string,
 	options: { debug: boolean } = { debug: false },
 ): string {
-	const parsedModule = parseExpression(moduleString, {
-		allowXQuery: true,
-		debug: options['debug'],
-	});
+	let parsedModule;
+	try {
+		parsedModule = parseExpression(moduleString, {
+			allowXQuery: true,
+			debug: options['debug'],
+		});
+	} catch (error) {
+		printAndRethrowError(moduleString, error);
+	}
 
 	annotateAst(parsedModule, new AnnotationContext(undefined));
 


Test patch:
diff --git a/test/specs/parsing/registerXQueryModule.tests.ts b/test/specs/parsing/registerXQueryModule.tests.ts
index be06d1c1..f4834560 100644
--- a/test/specs/parsing/registerXQueryModule.tests.ts
+++ b/test/specs/parsing/registerXQueryModule.tests.ts
@@ -345,4 +345,13 @@ declare function bar:baz() {
 			'XPST0017',
 		);
 	});
+
+	it('throws a proper error for parse errors', () => {
+		chai.expect(() => {
+			registerXQueryModule(
+				`declare function local:one() { 1 }(:missing semicolon:)
+				declare function local:two() { 2 };`,
+			);
+		}).to.throw('XPST0003: Failed to parse script. Expected ;');
+	});
 });
Repository: uber-go/fx (go)
Issue: signalReceivers should call `Signal.Stop(recv.signals)` when stopped
**Describe the bug**

signalReceivers should call `Signal.Stop(recv.signals)` when they are `Stop()`ed.

Because if not, then when a user does:
```
app.Start(...)
app.Close(...)

// block on anything else
select {} // for example
```

the program will fail to exit when the user presses ctrl-c. Which is contrary to what one would expect after starting and stopping the fx app.

**To Reproduce**

Example
```go
func main() {
	app := fx.New()
	app.Start(context.Background())
	app.Stop(context.Background())

	select {}
}
```

ctrl-c should exit the program

**Expected behavior**
the signal handler reverts back to Go's default signal handler

**Additional context**
should be a ~1 line change :)
Pull request description: Call signal.Stop when signalReceivers is stopped
fixes #1197 

Patch:
diff --git a/signal.go b/signal.go
index 71d2204..1b84568 100644
--- a/signal.go
+++ b/signal.go
@@ -46,8 +46,9 @@ func (sig ShutdownSignal) String() string {
 
 func newSignalReceivers() signalReceivers {
 	return signalReceivers{
-		notify:  signal.Notify,
-		signals: make(chan os.Signal, 1),
+		notify:     signal.Notify,
+		stopNotify: signal.Stop,
+		signals:    make(chan os.Signal, 1),
 	}
 }
 
@@ -64,7 +65,8 @@ type signalReceivers struct {
 	finished chan struct{}
 
 	// this stub allows us to unit test signal relay functionality
-	notify func(c chan<- os.Signal, sig ...os.Signal)
+	notify     func(c chan<- os.Signal, sig ...os.Signal)
+	stopNotify func(c chan<- os.Signal)
 
 	// last will contain a pointer to the last ShutdownSignal received, or
 	// nil if none, if a new channel is created by Wait or Done, this last
@@ -118,6 +120,7 @@ func (recv *signalReceivers) Start(ctx context.Context) {
 func (recv *signalReceivers) Stop(ctx context.Context) error {
 	recv.m.Lock()
 	defer recv.m.Unlock()
+	recv.stopNotify(recv.signals)
 
 	// if the relayer is not running; return nil error
 	if !recv.running() {


Test patch:
diff --git a/signal_test.go b/signal_test.go
index 8e8030a..95d6fe4 100644
--- a/signal_test.go
+++ b/signal_test.go
@@ -100,6 +100,10 @@ func TestSignal(t *testing.T) {
 						}
 					}()
 				}
+				var stopCalledTimes int
+				recv.stopNotify = func(ch chan<- os.Signal) {
+					stopCalledTimes++
+				}
 				ctx, cancel := context.WithCancel(context.Background())
 				defer cancel()
 				recv.Start(ctx)
@@ -110,6 +114,7 @@ func TestSignal(t *testing.T) {
 				sig := <-recv.Wait()
 				require.Equal(t, syscall.SIGTERM, sig.Signal)
 				require.NoError(t, recv.Stop(ctx))
+				require.Equal(t, 1, stopCalledTimes)
 				close(stub)
 			})
 		})
Repository: vaskoz/dailycodingproblem-go (go)
Issue: Day 120
Good morning! Here's your coding interview problem for today.

This problem was asked by Microsoft.

Implement the singleton pattern with a twist. First, instead of storing one instance, store two instances. And in every even call of `getInstance()`, return the first instance and in every odd call of `getInstance()`, return the second instance.
Pull request description: Day120
Resolves #248.

Patch:
diff --git a/README.md b/README.md
index ba424c0..a27ef47 100644
--- a/README.md
+++ b/README.md
@@ -126,3 +126,4 @@ problems from
 * [Day 114](https://github.com/vaskoz/dailycodingproblem-go/issues/237)
 * [Day 115](https://github.com/vaskoz/dailycodingproblem-go/issues/238)
 * [Day 116](https://github.com/vaskoz/dailycodingproblem-go/issues/242)
+* [Day 120](https://github.com/vaskoz/dailycodingproblem-go/issues/248)
diff --git a/day120/problem.go b/day120/problem.go
new file mode 100644
index 0000000..114abde
--- /dev/null
+++ b/day120/problem.go
@@ -0,0 +1,32 @@
+package day120
+
+// singleton represents any singleton object.
+type singleton struct {
+	t int
+}
+
+// global contains only number of call state.
+type global struct {
+	evenOrOdd int
+	even, odd *singleton
+}
+
+// Global represents a global context in which singletons exist.
+type Global interface {
+	GetInstance() interface{}
+}
+
+// New returns a new Global context.
+func New() Global {
+	return &global{evenOrOdd: 0, even: &singleton{0}, odd: &singleton{1}}
+}
+
+// GetInstance returns one of two possible singletons.
+// The returned singleton alternates between calls.
+func (g *global) GetInstance() interface{} {
+	g.evenOrOdd = (g.evenOrOdd + 1) % 2
+	if g.evenOrOdd == 0 {
+		return g.even
+	}
+	return g.odd
+}


Test patch:
diff --git a/day120/problem_test.go b/day120/problem_test.go
new file mode 100644
index 0000000..8f9961e
--- /dev/null
+++ b/day120/problem_test.go
@@ -0,0 +1,27 @@
+package day120
+
+import "testing"
+
+func TestGetInstance(t *testing.T) {
+	g := New()
+	first := g.GetInstance()
+	second := g.GetInstance()
+	if first == second {
+		t.Errorf("The first and second instance should not be the same")
+	}
+	for i := 0; i < 100; i++ {
+		if first != g.GetInstance() {
+			t.Errorf("First doesn't match")
+		}
+		if second != g.GetInstance() {
+			t.Errorf("Second doesn't match")
+		}
+	}
+}
+
+func BenchmarkGetInstance(b *testing.B) {
+	g := New()
+	for i := 0; i < b.N; i++ {
+		g.GetInstance()
+	}
+}