nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: goccy/go-yaml
Pull request #620 (2025-01-17 15:29:47)

Fix flow sequence with map
resolve https://github.com/goccy/go-yaml/issues/617#issuecomment-2596471928


Patch:
diff --git a/parser/parser.go b/parser/parser.go
index a3918fd..49334a2 100644
--- a/parser/parser.go
+++ b/parser/parser.go
@@ -533,7 +533,7 @@ func (p *parser) validateMapKeyValueNextToken(ctx *context, keyTk, tk *Token) er
 	if tk.Column() <= keyTk.Column() {
 		return nil
 	}
-	if ctx.isFlow && tk.Type() == token.CollectEntryType {
+	if ctx.isFlow && (tk.Type() == token.CollectEntryType || tk.Type() == token.SequenceEndType) {
 		return nil
 	}
 	// a: b


Test patch:
diff --git a/decode_test.go b/decode_test.go
index 6b99879..8ed7652 100644
--- a/decode_test.go
+++ b/decode_test.go
@@ -647,6 +647,23 @@ merge:
 			"v: [A,1,C]",
 			map[string]interface{}{"v": []interface{}{"A", 1, "C"}},
 		},
+		{
+			"v: [a: b, c: d]",
+			map[string]any{"v": []any{
+				map[string]any{"a": "b"},
+				map[string]any{"c": "d"},
+			}},
+		},
+		{
+			"v: [{a: b}, {c: d, e: f}]",
+			map[string]any{"v": []any{
+				map[string]any{"a": "b"},
+				map[string]any{
+					"c": "d",
+					"e": "f",
+				},
+			}},
+		},
 
 		// Block sequence
 		{
Repository: goccy/go-yaml
Pull request #654 (2025-02-12 06:17:36)

Fix format with empty value
Consider to empty flow mapping or empty flow sequence


Patch:
diff --git a/internal/format/format.go b/internal/format/format.go
index cc61d70..a4539ed 100644
--- a/internal/format/format.go
+++ b/internal/format/format.go
@@ -284,6 +284,9 @@ func (f *Formatter) formatFile(file *ast.File) string {
 }
 
 func (f *Formatter) origin(tk *token.Token) string {
+	if tk == nil {
+		return ""
+	}
 	if f.existsComment {
 		return tk.Origin
 	}
@@ -349,10 +352,6 @@ func (f *Formatter) formatDirective(n *ast.DirectiveNode) string {
 }
 
 func (f *Formatter) formatMapping(n *ast.MappingNode) string {
-	if len(n.Values) == 0 {
-		return "{}"
-	}
-
 	var ret string
 	if n.IsFlowStyle {
 		ret = f.origin(n.Start)
@@ -379,10 +378,6 @@ func (f *Formatter) formatMappingKey(n *ast.MappingKeyNode) string {
 }
 
 func (f *Formatter) formatSequence(n *ast.SequenceNode) string {
-	if len(n.Values) == 0 {
-		return "[]"
-	}
-
 	var ret string
 	if n.IsFlowStyle {
 		ret = f.origin(n.Start)


Test patch:
diff --git a/decode_test.go b/decode_test.go
index b7de871..15a1a73 100644
--- a/decode_test.go
+++ b/decode_test.go
@@ -3196,6 +3196,41 @@ foo:
 	}
 }
 
+func TestBytesUnmarshalerWithEmptyValue(t *testing.T) {
+	type T struct{}
+
+	unmarshaler := func(dst *T, b []byte) error {
+		var v any
+		return yaml.Unmarshal(b, &v)
+	}
+
+	yml := `
+map: &m {}
+seq: &seq []
+foo: # comment
+bar: *m
+baz: *seq
+`
+	m := yaml.CommentMap{}
+	var v T
+	if err := yaml.UnmarshalWithOptions(
+		[]byte(yml),
+		&v,
+		yaml.CommentToMap(m),
+		yaml.CustomUnmarshaler[T](unmarshaler),
+	); err != nil {
+		t.Fatal(err)
+	}
+	if err := yaml.UnmarshalWithOptions(
+		[]byte(yml),
+		&v,
+		yaml.CustomUnmarshaler[T](unmarshaler),
+	); err != nil {
+		t.Fatal(err)
+	}
+
+}
+
 func TestIssue650(t *testing.T) {
 	type Disk struct {
 		Name   string `yaml:"name"`
Repository: goccy/go-yaml
Pull request #657 (2025-02-15 02:50:16)

Fix encoding of string that contains "- "
fix https://github.com/goccy/go-yaml/issues/655

codecov-commenter: :warning: Please install the !['codecov app svg image'](https://github.com/codecov/engineering-team/assets/152432831/e90313f4-9d3a-4b63-8b54-cfe14e7ec20d) to ensure uploads and comments are reliably processed by Codecov.

## [Codecov](https://app.codecov.io/gh/goccy/go-yaml/pull/657?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Masaaki+Goshima) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 77.59%. Comparing base [(`2ac8cff`)](https://app.codecov.io/gh/goccy/go-yaml/commit/2ac8cffa276e56c4dc385f5bd2404c07152bb49b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Masaaki+Goshima) to head [(`8351730`)](https://app.codecov.io/gh/goccy/go-yaml/commit/83517308b0d28829ee727e21e9fa3507dbebab10?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Masaaki+Goshima).

:exclamation: Your organization needs to install the [Codecov GitHub app](https://github.com/apps/codecov/installations/select_target) to enable full functionality.

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##           master     #657   +/-   ##
=======================================
  Coverage   77.58%   77.59%           
=======================================
  Files          22       22           
  Lines        7840     7843    +3     
=======================================
+ Hits         6083     6086    +3     
  Misses       1345     1345           
  Partials      412      412           
```

</details>

Patch:
diff --git a/token/token.go b/token/token.go
index 54ab179..4fe300f 100644
--- a/token/token.go
+++ b/token/token.go
@@ -679,6 +679,9 @@ func IsNeedQuoted(value string) bool {
 	if isNumber(value) {
 		return true
 	}
+	if value == "-" {
+		return true
+	}
 	first := value[0]
 	switch first {
 	case '*', '&', '[', '{', '}', ']', ',', '!', '|', '>', '%', '\'', '"', '@', ' ', '`':
@@ -696,7 +699,7 @@ func IsNeedQuoted(value string) bool {
 		switch c {
 		case '#', '\\':
 			return true
-		case ':':
+		case ':', '-':
 			if i+1 < len(value) && value[i+1] == ' ' {
 				return true
 			}


Test patch:
diff --git a/encode_test.go b/encode_test.go
index b4f3913..be377c4 100644
--- a/encode_test.go
+++ b/encode_test.go
@@ -171,7 +171,7 @@ func TestEncoder(t *testing.T) {
 			},
 		},
 		{
-			"a: -\n",
+			"a: \"-\"\n",
 			map[string]string{"a": "-"},
 			nil,
 		},
diff --git a/token/token_test.go b/token/token_test.go
index 3b339b4..489a531 100644
--- a/token/token_test.go
+++ b/token/token_test.go
@@ -133,6 +133,8 @@ func TestIsNeedQuoted(t *testing.T) {
 		"Null",
 		"NULL",
 		"~",
+		"-",
+		"- --foo",
 	}
 	for i, test := range needQuotedTests {
 		if !token.IsNeedQuoted(test) {
Repository: goccy/go-yaml
Pull request #683 (2025-03-31 11:18:56)

Fix unmarshaler with comment
SSIA


Patch:
diff --git a/internal/format/format.go b/internal/format/format.go
index a4539ed..2d55652 100644
--- a/internal/format/format.go
+++ b/internal/format/format.go
@@ -335,14 +335,10 @@ func (f *Formatter) formatMergeKey(n *ast.MergeKeyNode) string {
 
 func (f *Formatter) formatMappingValue(n *ast.MappingValueNode) string {
 	return f.formatCommentGroup(n.Comment) +
-		f.formatMapKey(n.Key) + ":" + f.formatNode(n.Value) +
+		f.origin(n.Key.GetToken()) + ":" + f.formatCommentGroup(n.Key.GetComment()) + f.formatNode(n.Value) +
 		f.formatCommentGroup(n.FootComment)
 }
 
-func (f *Formatter) formatMapKey(n ast.MapKeyNode) string {
-	return f.formatCommentGroup(n.GetComment()) + f.formatNode(n)
-}
-
 func (f *Formatter) formatDirective(n *ast.DirectiveNode) string {
 	ret := f.origin(n.Start) + f.formatNode(n.Name)
 	for _, val := range n.Values {
@@ -382,6 +378,10 @@ func (f *Formatter) formatSequence(n *ast.SequenceNode) string {
 	if n.IsFlowStyle {
 		ret = f.origin(n.Start)
 	}
+	if n.Comment != nil {
+		// add head comment.
+		ret += f.formatCommentGroup(n.Comment)
+	}
 	for _, entry := range n.Entries {
 		ret += f.formatNode(entry)
 	}


Test patch:
diff --git a/decode_test.go b/decode_test.go
index 9aa9ee1..7a390fc 100644
--- a/decode_test.go
+++ b/decode_test.go
@@ -2223,6 +2223,42 @@ map: &map
 	})
 }
 
+func TestCommentWithCustomUnmarshaler(t *testing.T) {
+	type T struct{}
+
+	for idx, test := range []string{
+		`
+foo:
+  # comment
+  - a: b
+`,
+		`
+foo: # comment
+  bar: 1
+  baz: true
+`,
+	} {
+		t.Run(strconv.Itoa(idx), func(t *testing.T) {
+			m := yaml.CommentMap{}
+			var v T
+			if err := yaml.UnmarshalWithOptions(
+				[]byte(test),
+				&v,
+				yaml.CommentToMap(m),
+				yaml.CustomUnmarshaler[T](func(dst *T, b []byte) error {
+					expected := bytes.Trim([]byte(test), "\n")
+					if !bytes.Equal(b, expected) {
+						return fmt.Errorf("failed to decode: got\n%s", string(test))
+					}
+					return nil
+				}),
+			); err != nil {
+				t.Fatal(err)
+			}
+		})
+	}
+}
+
 func ExampleUnmarshal_jSONTags() {
 	yml := `---
 foo: 1
Repository: goccy/go-yaml
Pull request #719 (2025-05-06 14:46:24)

Add nil checking for error handling
fix https://github.com/goccy/go-yaml/issues/718


Patch:
diff --git a/internal/errors/error.go b/internal/errors/error.go
index 1647e36..b08a3fc 100644
--- a/internal/errors/error.go
+++ b/internal/errors/error.go
@@ -234,6 +234,9 @@ func (e *UnexpectedNodeTypeError) msg() string {
 
 func FormatError(errMsg string, token *token.Token, colored, inclSource bool) string {
 	var pp printer.Printer
+	if token == nil {
+		return pp.PrintErrorMessage(errMsg, colored)
+	}
 	pos := fmt.Sprintf("[%d:%d] ", token.Position.Line, token.Position.Column)
 	msg := pp.PrintErrorMessage(fmt.Sprintf("%s%s", pos, errMsg), colored)
 	if inclSource {
diff --git a/parser/parser.go b/parser/parser.go
index 3da78fb..992f4ea 100644
--- a/parser/parser.go
+++ b/parser/parser.go
@@ -400,7 +400,11 @@ func (p *parser) parseFlowMap(ctx *context) (*ast.MappingNode, error) {
 			}
 		default:
 			if !p.isFlowMapDelim(ctx.nextToken()) {
-				return nil, errors.ErrSyntax("could not find flow map content", mapKeyTk.RawToken())
+				errTk := mapKeyTk
+				if errTk == nil {
+					errTk = tk
+				}
+				return nil, errors.ErrSyntax("could not find flow map content", errTk.RawToken())
 			}
 			key, err := p.parseScalarValue(ctx, mapKeyTk)
 			if err != nil {


Test patch:
diff --git a/fuzz_test.go b/fuzz_test.go
index 3485197..d1208a8 100644
--- a/fuzz_test.go
+++ b/fuzz_test.go
@@ -34,6 +34,8 @@ verified: true
 		"0\n0\n0\n0\n0\n0",
 		"0\n0\n0\n0\n0\n0\n",
 		"",
+		"00A: 0000A",
+		"{\"000\":0000A,",
 	}
 
 	f.Add([]byte(validYAML))
@@ -47,6 +49,8 @@ verified: true
 
 	f.Fuzz(func(t *testing.T, src []byte) {
 		v := map[string]any{}
-		_ = yaml.Unmarshal(src, &v)
+		if err := yaml.Unmarshal(src, &v); err != nil {
+			t.Log(err.Error())
+		}
 	})
 }
diff --git a/parser/parser_test.go b/parser/parser_test.go
index 1b86a3a..d8a52bc 100644
--- a/parser/parser_test.go
+++ b/parser/parser_test.go
@@ -1424,6 +1424,14 @@ foo:
    6 |     foo: 3
 >  7 |     foo: 4
            ^
+`,
+		},
+		{
+			`{"000":0000A,`,
+			`
+[1:13] could not find flow map content
+>  1 | {"000":0000A,
+                   ^
 `,
 		},
 	}
Repository: goccy/go-yaml
Pull request #720 (2025-05-07 03:27:38)

Ignore validation for alias map key
ref #712 

codecov-commenter: :warning: Please install the !['codecov app svg image'](https://github.com/codecov/engineering-team/assets/152432831/e90313f4-9d3a-4b63-8b54-cfe14e7ec20d) to ensure uploads and comments are reliably processed by Codecov.

## [Codecov](https://app.codecov.io/gh/goccy/go-yaml/pull/720?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Masaaki+Goshima) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 77.87%. Comparing base [(`55ca112`)](https://app.codecov.io/gh/goccy/go-yaml/commit/55ca11205f051fe5daa6dfe631ac30dc08a0dab7?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Masaaki+Goshima) to head [(`5087814`)](https://app.codecov.io/gh/goccy/go-yaml/commit/50878148c1bcf32bc6a405876366806c2565cf41?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Masaaki+Goshima).

:exclamation: Your organization needs to install the [Codecov GitHub app](https://github.com/apps/codecov/installations/select_target) to enable full functionality.

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##           master     #720   +/-   ##
=======================================
  Coverage   77.87%   77.87%           
=======================================
  Files          22       22           
  Lines        7986     7986           
=======================================
  Hits         6219     6219           
  Misses       1352     1352           
  Partials      415      415           
```

</details>
<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
</details>

Patch:
diff --git a/parser/parser.go b/parser/parser.go
index 992f4ea..b3319f1 100644
--- a/parser/parser.go
+++ b/parser/parser.go
@@ -705,7 +705,7 @@ func (p *parser) mapKeyText(n ast.Node) string {
 	case *ast.AnchorNode:
 		return p.mapKeyText(nn.Value)
 	case *ast.AliasNode:
-		return p.mapKeyText(nn.Value)
+		return ""
 	}
 	return n.GetToken().Value
 }


Test patch:
diff --git a/decode_test.go b/decode_test.go
index 7a390fc..a6a6696 100644
--- a/decode_test.go
+++ b/decode_test.go
@@ -1023,6 +1023,10 @@ merge:
 				},
 			},
 		},
+		{
+			`{a: &a c, *a : b}`,
+			map[string]string{"a": "c", "c": "b"},
+		},
 		{
 			"tags:\n- hello-world\na: foo",
 			struct {
diff --git a/parser/parser_test.go b/parser/parser_test.go
index d8a52bc..85aeb99 100644
--- a/parser/parser_test.go
+++ b/parser/parser_test.go
@@ -160,6 +160,7 @@ v:
   b	: 'y'
   c		: 'z'
 `,
+		`{a: &a c, *a : b}`,
 	}
 	for idx, src := range sources {
 		t.Run(strconv.Itoa(idx), func(t *testing.T) {
Repository: goccy/go-yaml
Pull request #743 (2025-05-23 07:05:46)

Prevent panic when decoding string named types
Closes https://github.com/goccy/go-yaml/issues/741

Previously, decoding string named type fields returned the converted string values directly, which could lead to a panic if the types didn’t match. This update adds a type check and performs the conversion if the types do not match.


Before submitting your PR, please confirm the following.

- [x] Describe the purpose for which you created this PR.  
- [x] Create test code that corresponds to the modification


Patch:
diff --git a/decode.go b/decode.go
index 15fcba2..b80901f 100644
--- a/decode.go
+++ b/decode.go
@@ -637,20 +637,29 @@ func (d *Decoder) convertValue(v reflect.Value, typ reflect.Type, src ast.Node)
 		return v.Convert(typ), nil
 	}
 	// cast value to string
+	var strVal string
 	switch v.Type().Kind() {
 	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
-		return reflect.ValueOf(strconv.FormatInt(v.Int(), 10)), nil
+		strVal = strconv.FormatInt(v.Int(), 10)
 	case reflect.Float32, reflect.Float64:
-		return reflect.ValueOf(fmt.Sprint(v.Float())), nil
+		strVal = fmt.Sprint(v.Float())
 	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
-		return reflect.ValueOf(strconv.FormatUint(v.Uint(), 10)), nil
+		strVal = strconv.FormatUint(v.Uint(), 10)
 	case reflect.Bool:
-		return reflect.ValueOf(strconv.FormatBool(v.Bool())), nil
+		strVal = strconv.FormatBool(v.Bool())
+	default:
+		if !v.Type().ConvertibleTo(typ) {
+			return reflect.Zero(typ), errors.ErrTypeMismatch(typ, v.Type(), src.GetToken())
+		}
+		return v.Convert(typ), nil
 	}
-	if !v.Type().ConvertibleTo(typ) {
-		return reflect.Zero(typ), errors.ErrTypeMismatch(typ, v.Type(), src.GetToken())
+
+	val := reflect.ValueOf(strVal)
+	if val.Type() != typ {
+		// Handle named types, e.g., `type MyString string`
+		val = val.Convert(typ)
 	}
-	return v.Convert(typ), nil
+	return val, nil
 }
 
 func (d *Decoder) deleteStructKeys(structType reflect.Type, unknownFields map[string]ast.Node) error {


Test patch:
diff --git a/decode_test.go b/decode_test.go
index 2623e39..e3833ea 100644
--- a/decode_test.go
+++ b/decode_test.go
@@ -25,6 +25,8 @@ type Child struct {
 	C int `yaml:"-"`
 }
 
+type TestString string
+
 func TestDecoder(t *testing.T) {
 	tests := []struct {
 		source string
@@ -35,6 +37,10 @@ func TestDecoder(t *testing.T) {
 			source: "v: hi\n",
 			value:  map[string]string{"v": "hi"},
 		},
+		{
+			source: "v: hi\n",
+			value:  map[string]TestString{"v": "hi"},
+		},
 		{
 			source: "v: \"true\"\n",
 			value:  map[string]string{"v": "true"},
@@ -55,6 +61,10 @@ func TestDecoder(t *testing.T) {
 			source: "v: 10\n",
 			value:  map[string]string{"v": "10"},
 		},
+		{
+			source: "v: 10\n",
+			value:  map[string]TestString{"v": "10"},
+		},
 		{
 			source: "v: -10\n",
 			value:  map[string]string{"v": "-10"},
Repository: goby-lang/goby
Pull request #854 (2020-06-30 00:19:21)

Update the instance method `last()` on array objects to not panic when used with an empty array
- Solves https://github.com/goby-lang/goby/issues/853:
```ruby
a = []
a.last # => nil
```

- Adds more tests to ensure the correct types are returned based on whether an argument is passed in or not to the `last()` method:

```ruby
a = [2, 6, 3, 4]
a.last    # => 4
a.last(1) # => [4]
```


Patch:
diff --git a/vm/array.go b/vm/array.go
index 2a30406..f03026c 100644
--- a/vm/array.go
+++ b/vm/array.go
@@ -1017,6 +1017,10 @@ var builtinArrayInstanceMethods = []*BuiltinMethodObject{
 			arrLength := len(arr.Elements)
 
 			if aLen == 0 {
+				if arrLength == 0 {
+					return NULL
+				}
+
 				return arr.Elements[arrLength-1]
 			}
 


Test patch:
diff --git a/vm/array_test.go b/vm/array_test.go
index 039a451..7e85d78 100644
--- a/vm/array_test.go
+++ b/vm/array_test.go
@@ -1349,8 +1349,20 @@ func TestArrayJoinMethodFail(t *testing.T) {
 func TestArrayLastMethod(t *testing.T) {
 	testsArray := []struct {
 		input    string
-		expected []interface{}
+		expected interface{}
 	}{
+		{`
+		a = []
+		a.last
+		`, nil},
+		{`
+		a = [2, 9, 7, 1, 8]
+		a.last
+		`, 8},
+		{`
+		a = [2, 9, 7, 1, 8]
+		a.last(1)
+		`, []interface{}{8}},
 		{`
 		a = [3, 4, 5, 1, 6]
 		a.last(3)
@@ -1372,7 +1384,7 @@ func TestArrayLastMethod(t *testing.T) {
 	for i, tt := range testsArray {
 		vm := initTestVM()
 		evaluated := vm.testEval(t, tt.input, getFilename())
-		verifyArrayObject(t, i, evaluated, tt.expected)
+		VerifyExpected(t, i, evaluated, tt.expected)
 		vm.checkCFP(t, i, 0)
 		vm.checkSP(t, i, 1)
 	}
Repository: goby-lang/goby
Pull request #862 (2020-10-22 15:34:50)

Add URI.parse argument check


Patch:
diff --git a/vm/uri.go b/vm/uri.go
index d27496e..26b669b 100644
--- a/vm/uri.go
+++ b/vm/uri.go
@@ -4,6 +4,7 @@ import (
 	"net/url"
 	"strconv"
 
+	"github.com/goby-lang/goby/vm/classes"
 	"github.com/goby-lang/goby/vm/errors"
 )
 
@@ -21,6 +22,16 @@ var builtinURIClassMethods = []*BuiltinMethodObject{
 		// ```
 		Name: "parse",
 		Fn: func(receiver Object, sourceLine int, t *Thread, args []Object, blockFrame *normalCallFrame) Object {
+			if len(args) != 1 {
+				return t.vm.InitErrorObject(errors.ArgumentError, sourceLine, errors.WrongNumberOfArgument, 1, len(args))
+			}
+
+			typeErr := t.vm.checkArgTypes(args, sourceLine, classes.StringClass)
+
+			if typeErr != nil {
+				return typeErr
+			}
+
 			uri := args[0].(*StringObject).value
 			uriModule := t.vm.TopLevelClass("URI")
 			u, err := url.Parse(uri)


Test patch:
diff --git a/vm/uri_test.go b/vm/uri_test.go
index c0870de..46edae3 100644
--- a/vm/uri_test.go
+++ b/vm/uri_test.go
@@ -90,3 +90,30 @@ func TestURIParsing(t *testing.T) {
 		v.checkSP(t, i, 1)
 	}
 }
+
+func TestURIParsingFail(t *testing.T) {
+	testsFail := []errorTestCase{
+		// No argument
+		{`
+		require "uri"
+		URI.parse
+		`, "ArgumentError: Expect 1 argument(s). got: 0", 1},
+		// Unexcpeted arguments
+		{`
+		require "uri"
+		URI.parse("foo", "bar")
+		`, "ArgumentError: Expect 1 argument(s). got: 2", 1},
+		// Invalid argument type
+		{`
+		require "uri"
+		URI.parse 1
+		`, "TypeError: Expect argument to be String. got: Integer", 1},
+	}
+	for i, tt := range testsFail {
+		v := initTestVM()
+		evaluated := v.testEval(t, tt.input, getFilename())
+		checkErrorMsg(t, i, evaluated, tt.expected)
+		v.checkCFP(t, i, tt.expectedCFP)
+		v.checkSP(t, i, 1)
+	}
+}
Repository: goby-lang/goby
Pull request #863 (2020-10-25 13:44:57)

Add fragment on URI
Ruby has the same API.


Patch:
diff --git a/vm/uri.go b/vm/uri.go
index 26b669b..8d3fcf1 100644
--- a/vm/uri.go
+++ b/vm/uri.go
@@ -45,6 +45,7 @@ var builtinURIClassMethods = []*BuiltinMethodObject{
 				"@password": NULL,
 				"@query":    NULL,
 				"@path":     t.vm.InitStringObject("/"),
+				"@fragment": NULL,
 			}
 
 			// Scheme
@@ -92,6 +93,11 @@ var builtinURIClassMethods = []*BuiltinMethodObject{
 				}
 			}
 
+			// Fragment
+			if u.Fragment != "" {
+				uriAttrs["@fragment"] = t.vm.InitStringObject(u.Fragment)
+			}
+
 			var c *RClass
 
 			if u.Scheme == "https" {
@@ -134,6 +140,7 @@ func initURIClass(vm *VM) {
 		vm.InitStringObject("scheme"),
 		vm.InitStringObject("user"),
 		vm.InitStringObject("password"),
+		vm.InitStringObject("fragment"),
 	}
 
 	http.setAttrReader(attrs)


Test patch:
diff --git a/vm/uri_test.go b/vm/uri_test.go
index 46edae3..a7827c6 100644
--- a/vm/uri_test.go
+++ b/vm/uri_test.go
@@ -80,6 +80,12 @@ func TestURIParsing(t *testing.T) {
 		u = URI.parse("https://example.com")
 		u.password
 		`, nil},
+		// Fragment
+		{`
+		require "uri"
+		u = URI.parse("https://example.com#id1")
+		u.fragment
+		`, "id1"},
 	}
 
 	for i, tt := range tests {
Repository: goby-lang/goby
Pull request #865 (2020-10-27 14:55:11)

Add Net::HTTP methods check


Patch:
diff --git a/vm/http.go b/vm/http.go
index b838689..6b65007 100644
--- a/vm/http.go
+++ b/vm/http.go
@@ -28,6 +28,10 @@ var builtinHTTPClassMethods = []*BuiltinMethodObject{
 		// Sends a GET request to the target and returns the HTTP response as a string. Will error on non-200 responses, for more control over http requests look at the `start` method.
 		Name: "get",
 		Fn: func(receiver Object, sourceLine int, t *Thread, args []Object, blockFrame *normalCallFrame) Object {
+			if len(args) < 1 {
+				return t.vm.InitErrorObject(errors.ArgumentError, sourceLine, errors.WrongNumberOfArgumentMore, 1, len(args))
+			}
+
 			arg0, ok := args[0].(*StringObject)
 			if !ok {
 				return t.vm.InitErrorObject(errors.ArgumentError, sourceLine, errors.WrongArgumentTypeFormatNum, 0, "String", args[0].Class().Name)
@@ -115,6 +119,10 @@ var builtinHTTPClassMethods = []*BuiltinMethodObject{
 		// Sends a HEAD request to the target with type header and body. Returns the HTTP headers as a map[string]string. Will error on non-200 responses, for more control over http requests look at the `start` method.
 		Name: "head",
 		Fn: func(receiver Object, sourceLine int, t *Thread, args []Object, blockFrame *normalCallFrame) Object {
+			if len(args) < 1 {
+				return t.vm.InitErrorObject(errors.ArgumentError, sourceLine, errors.WrongNumberOfArgumentMore, 1, len(args))
+			}
+
 			arg0, ok := args[0].(*StringObject)
 			if !ok {
 				return t.vm.InitErrorObject(errors.ArgumentError, sourceLine, errors.WrongArgumentTypeFormatNum, 0, "String", args[0].Class().Name)


Test patch:
diff --git a/vm/http_test.go b/vm/http_test.go
index fe65a6a..d30c6e5 100644
--- a/vm/http_test.go
+++ b/vm/http_test.go
@@ -77,6 +77,18 @@ func TestHTTPRequestFail(t *testing.T) {
 
 		Net::HTTP.get(42)
 		`, "ArgumentError: Expect argument #0 to be String. got: Integer", 1},
+		//Zero argument for get()
+		{`
+		require "net/http"
+
+		Net::HTTP.get
+		`, "ArgumentError: Expect 1 or more argument(s). got: 0", 1},
+		//Zero argument for head()
+		{`
+		require "net/http"
+
+		Net::HTTP.head
+		`, "ArgumentError: Expect 1 or more argument(s). got: 0", 1},
 		{`
 		require "net/http"