nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: goplus/gop
Pull request #477 (2020-07-18 18:35:42)

Autoprop


Patch:
diff --git a/cl/expr.go b/cl/expr.go
index 459690e1..4eec31f9 100644
--- a/cl/expr.go
+++ b/cl/expr.go
@@ -946,16 +946,17 @@ func compileSelectorExpr(ctx *blockCtx, v *ast.SelectorExpr) func() {
 	case *nonValue:
 		switch nv := vx.v.(type) {
 		case exec.GoPackage:
-			if c, ok := nv.FindConst(v.Sel.Name); ok {
+			name := strings.Title(v.Sel.Name)
+			if c, ok := nv.FindConst(name); ok {
 				ret := newConstVal(c.Value, c.Kind)
 				ctx.infer.Ret(1, ret)
 				return func() {
 					pushConstVal(ctx.out, ret)
 				}
 			}
-			addr, kind, ok := nv.Find(v.Sel.Name)
+			addr, kind, ok := nv.Find(name)
 			if !ok {
-				log.Panicln("compileSelectorExpr: not found -", nv.PkgPath(), v.Sel.Name)
+				log.Panicln("compileSelectorExpr: not found -", nv.PkgPath(), name)
 			}
 			switch kind {
 			case exec.SymbolFunc, exec.SymbolFuncv:
@@ -988,11 +989,14 @@ func compileSelectorExpr(ctx *blockCtx, v *ast.SelectorExpr) func() {
 		}
 		if _, ok := vx.t.MethodByName(name); !ok && isLower(name) {
 			name = strings.Title(name)
-			if _, ok = vx.t.MethodByName(name); !ok {
+			if m, ok := vx.t.MethodByName(name); ok {
+				if m.Type.NumIn() == 1 {
+					v.Sel.Name = name
+					return compileCallExpr(ctx, &ast.CallExpr{Fun: v})
+				}
+			} else {
 				log.Panicln("compileSelectorExpr: symbol not found -", v.Sel.Name)
 			}
-			v.Sel.Name = name
-			return compileCallExpr(ctx, &ast.CallExpr{Fun: v})
 		}
 		pkgPath, method := normalizeMethod(n, t, name)
 		pkg := ctx.FindGoPackage(pkgPath)


Test patch:
diff --git a/cl/expr_test.go b/cl/expr_test.go
index 2ecf823b..3b17d033 100644
--- a/cl/expr_test.go
+++ b/cl/expr_test.go
@@ -29,9 +29,9 @@ func TestAutoProperty(t *testing.T) {
 		import "bytes"
 		import "os"
 
-		b := bytes.NewBuffer(nil)
-		b.WriteString("Hello, ")
-		b.WriteString("Go+")
+		b := bytes.newBuffer(nil)
+		b.writeString("Hello, ")
+		b.writeString("Go+")
 		println(b.string)
 		`,
 		"Hello, Go+\n",
@@ -40,14 +40,22 @@ func TestAutoProperty(t *testing.T) {
 		import "bytes"
 		import "os"
 
-		b := bytes.NewBuffer(nil)
-		b.WriteString("Hello, ")
-		b.WriteString("Go+")
+		b := bytes.newBuffer(nil)
+		b.writeString("Hello, ")
+		b.writeString("Go+")
 		println(b.string2)
 		`,
 		"",
 		nil, // panic
 	)
+	cltest.Expect(t, `
+		import "bytes"
+
+		bytes.newBuf()
+		`,
+		"",
+		nil, // panic
+	)
 }
 
 func TestUnbound(t *testing.T) {
Repository: goplus/gop
Pull request #546 (2020-08-12 10:02:58)

ast.ParenExpr  isNoExecCtxExpr fixed
#545 

codecov-commenter: # [Codecov](https://codecov.io/gh/goplus/gop/pull/546?src=pr&el=h1) Report
> Merging [#546](https://codecov.io/gh/goplus/gop/pull/546?src=pr&el=desc) into [master](https://codecov.io/gh/goplus/gop/commit/4ee8417fa1cb23a057aca51b104c90f469b91365&el=desc) will **decrease** coverage by `0.01%`.
> The diff coverage is `0.00%`.

[![Impacted file tree graph](https://codecov.io/gh/goplus/gop/pull/546/graphs/tree.svg?width=650&height=150&src=pr&token=4qln9Wk3Pn)](https://codecov.io/gh/goplus/gop/pull/546?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #546      +/-   ##
==========================================
- Coverage   89.88%   89.86%   -0.02%     
==========================================
  Files          40       40              
  Lines       10190    10192       +2     
==========================================
  Hits         9159     9159              
- Misses        752      754       +2     
  Partials      279      279              
```


| [Impacted Files](https://codecov.io/gh/goplus/gop/pull/546?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [cl/ctx\_check.go](https://codecov.io/gh/goplus/gop/pull/546/diff?src=pr&el=tree#diff-Y2wvY3R4X2NoZWNrLmdv) | `75.50% <0.00%> (-0.62%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/goplus/gop/pull/546?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/goplus/gop/pull/546?src=pr&el=footer). Last update [4ee8417...223961f](https://codecov.io/gh/goplus/gop/pull/546?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/cl/ctx_check.go b/cl/ctx_check.go
index 0b8b9976..0211ede5 100644
--- a/cl/ctx_check.go
+++ b/cl/ctx_check.go
@@ -102,6 +102,8 @@ func isNoExecCtxExpr(ctx *blockCtx, expr ast.Expr) bool {
 		return isNoExecCtxExpr(ctx, v.X)
 	case *ast.SelectorExpr:
 		return isNoExecCtxExpr(ctx, v.X)
+	case *ast.ParenExpr:
+		return isNoExecCtxExpr(ctx, v.X)
 	case *ast.ErrWrapExpr:
 		return isNoExecCtx2nd(ctx, v.X, v.Default)
 	case *ast.IndexExpr:


Test patch:
diff --git a/exec/golang/testdata/11.for-loop/for.gop b/exec/golang/testdata/11.for-loop/for.gop
index 06a18bee..8e33693f 100644
--- a/exec/golang/testdata/11.for-loop/for.gop
+++ b/exec/golang/testdata/11.for-loop/for.gop
@@ -101,3 +101,8 @@ for i := 0; i < len(arr); i++ {
 	}
 }
 println("sum==36", sum == 36, sum)
+
+// issues #545
+for k <- [1, 2] {
+	println(k, (k+1)%2)
+}
Repository: goplus/gop
Pull request #642 (2021-01-02 06:52:26)

golang: support inc/dec for BigInt/BigRat/BigFloat
Go+ code
```
for i := 1r; i < 10r; i++ {
	println(i)
}
```
generate Golang code
```
package main

import (
	fmt "fmt"
	big "math/big"
)

func main() {
	{
		var i *big.Int
//line ./main.gop:2
		i = big.NewInt(1)
//line ./main.gop:2
		goto _gop_1
	_gop_1:
//line ./main.gop:2
		if !(i.Cmp(big.NewInt(10)) < 0) {
			goto _gop_2
		}
//line ./main.gop:3
		fmt.Println(i)
//line ./main.gop:2
		goto _gop_3
//line ./main.gop:2
		goto _gop_3
	_gop_3:
//line ./main.gop:2
		i.Add(i, big.NewInt(1))
//line ./main.gop:2
		goto _gop_1
//line ./main.gop:2
		goto _gop_2
	_gop_2:
	}
}
```


Patch:
diff --git a/exec/golang/var.go b/exec/golang/var.go
index d62d6fd1..aa91a96e 100644
--- a/exec/golang/var.go
+++ b/exec/golang/var.go
@@ -198,6 +198,25 @@ func (p *Builder) bigAddrOp(kind exec.Kind, op exec.AddrOperator) *Builder {
 	var expr ast.Expr
 	var x = p.rhs.Pop()
 	var val = p.rhs.Pop().(ast.Expr)
+	if op == exec.OpInc || op == exec.OpDec {
+		switch kind {
+		case exec.BigInt:
+			val = &ast.CallExpr{
+				Fun:  p.GoSymIdent("math/big", "NewInt"),
+				Args: []ast.Expr{&ast.Ident{Name: "1"}},
+			}
+		case exec.BigRat:
+			val = &ast.CallExpr{
+				Fun:  p.GoSymIdent("math/big", "NewRat"),
+				Args: []ast.Expr{&ast.Ident{Name: "1"}, &ast.Ident{Name: "1"}},
+			}
+		case exec.BigFloat:
+			val = &ast.CallExpr{
+				Fun:  p.GoSymIdent("math/big", "NewFloat"),
+				Args: []ast.Expr{&ast.Ident{Name: "1"}},
+			}
+		}
+	}
 	switch v := x.(type) {
 	case *ast.UnaryExpr:
 		if v.Op != token.AND {
diff --git a/go.sum b/go.sum
index 1d574965..5c84c114 100644
--- a/go.sum
+++ b/go.sum
@@ -1,6 +1,8 @@
 github.com/goplus/reflectx v0.3.1 h1:qf45CZJfo4VqbuMFyOjrjnF7LDIHoB9c6ltbejQLuvw=
 github.com/goplus/reflectx v0.3.1/go.mod h1:XPDe5lYQ/8FN05bhqv6r1hhLxwmYIkZ5UvIkN1GNRYg=
+github.com/mattn/go-runewidth v0.0.3 h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4=
 github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
+github.com/peterh/liner v1.2.0 h1:w/UPXyl5GfahFxcTOz2j9wCIHNI+pUPr2laqpojKNCg=
 github.com/peterh/liner v1.2.0/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
 github.com/qiniu/x v1.11.5 h1:TYr5cl4g2yoHAZeDK4MTjKF6CMoG+IHlCDvvM5qym6U=
 github.com/qiniu/x v1.11.5/go.mod h1:03Ni9tj+N2h2aKnAz+6N0Xfl8FwMEDRC2PAlxekASDs=


Test patch:
diff --git a/exec/golang/testdata/19.rational/rational.gop b/exec/golang/testdata/19.rational/rational.gop
index 22bab39f..47f36f09 100644
--- a/exec/golang/testdata/19.rational/rational.gop
+++ b/exec/golang/testdata/19.rational/rational.gop
@@ -1,7 +1,14 @@
 a := 1r << 65 // bigint, large than int64
 b := 4/5r     // bigrat
 c := b - 1/3r + 3*1/2r
-println(a, b, c)
+d := 1.5r
+println(a, b, c, d)
+
+a++
+b++
+c--
+d++
+println(a, b, c, d)
 
 x := 3.14159265358979323846264338327950288419716939937510582097494459r
 x *= 2
Repository: goplus/gop
Pull request #925 (2021-11-22 15:34:22)

cl: switch check more duplicate


Patch:
diff --git a/cl/stmt.go b/cl/stmt.go
index 6173bd5e..a5065392 100644
--- a/cl/stmt.go
+++ b/cl/stmt.go
@@ -440,8 +440,10 @@ func compileSwitchStmt(ctx *blockCtx, v *ast.SwitchStmt) {
 				// look for duplicate types for a given value
 				// (quadratic algorithm, but these lists tend to be very short)
 				typ := types.Default(v.Type)
+				var haserr bool
 				for _, vt := range seen[val] {
 					if types.Identical(typ, vt.typ) {
+						haserr = true
 						src, pos := ctx.LoadExpr(v.Src)
 						if _, ok := v.Src.(*ast.BasicLit); ok {
 							ctx.handleCodeErrorf(&pos, "duplicate case %s in switch\n\tprevious case at %v",
@@ -452,15 +454,18 @@ func compileSwitchStmt(ctx *blockCtx, v *ast.SwitchStmt) {
 						}
 					}
 				}
-				seen[val] = append(seen[val], valueType{v.Src.Pos(), typ})
+				if !haserr {
+					seen[val] = append(seen[val], valueType{v.Src.Pos(), typ})
+				}
 			}
 		}
 		if c.List == nil {
 			if firstDefault != nil {
 				pos := ctx.Position(c.Pos())
 				ctx.handleCodeErrorf(&pos, "multiple defaults in switch (first at %v)", ctx.Position(firstDefault.Pos()))
+			} else {
+				firstDefault = c
 			}
-			firstDefault = c
 		}
 		cb.Case(len(c.List)) // Case(0) means default case
 		body, has := hasFallthrough(c.Body)


Test patch:
diff --git a/cl/error_msg_test.go b/cl/error_msg_test.go
index bf0de0db..affef670 100644
--- a/cl/error_msg_test.go
+++ b/cl/error_msg_test.go
@@ -680,6 +680,17 @@ const v = "hello"
 switch n {
 	case "hello":
 	case v:
+}`)
+	codeErrorTest(t,
+		`./bar.gop:4:7: duplicate case 100 in switch
+	previous case at ./bar.gop:3:7
+./bar.gop:5:7: duplicate case 50 + 50 (value 100) in switch
+	previous case at ./bar.gop:3:7`,
+		`var n int
+switch n {
+	case 100:
+	case 100:
+	case 50 + 50:
 }`)
 	codeErrorTest(t,
 		"./bar.gop:4:2: multiple defaults in switch (first at ./bar.gop:3:2)",
@@ -687,5 +698,13 @@ switch n {
 switch n {
 	default:
 	default:
+}`)
+	codeErrorTest(t, `./bar.gop:4:2: multiple defaults in switch (first at ./bar.gop:3:2)
+./bar.gop:5:2: multiple defaults in switch (first at ./bar.gop:3:2)`,
+		`var n interface{}
+switch n {
+	default:
+	default:
+	default:
 }`)
 }
Repository: goplus/gop
Pull request #926 (2021-11-22 23:11:05)

cl: type switch check duplicate


Patch:
diff --git a/cl/stmt.go b/cl/stmt.go
index a5065392..2161cb7b 100644
--- a/cl/stmt.go
+++ b/cl/stmt.go
@@ -388,6 +388,8 @@ func compileTypeSwitchStmt(ctx *blockCtx, v *ast.TypeSwitchStmt) {
 	}
 	compileExpr(ctx, ta.X)
 	cb.TypeAssertThen()
+	seen := make(map[types.Type]ast.Expr)
+	var firstDefault ast.Stmt
 	for _, stmt := range v.Body.List {
 		c, ok := stmt.(*ast.CaseClause)
 		if !ok {
@@ -395,6 +397,33 @@ func compileTypeSwitchStmt(ctx *blockCtx, v *ast.TypeSwitchStmt) {
 		}
 		for _, citem := range c.List {
 			compileExpr(ctx, citem)
+			T := cb.Get(-1).Type
+			if tt, ok := T.(*gox.TypeType); ok {
+				T = tt.Type()
+			}
+			var haserr bool
+			for t, other := range seen {
+				if T == nil && t == nil || T != nil && t != nil && types.Identical(T, t) {
+					haserr = true
+					pos := ctx.Position(citem.Pos())
+					if T == types.Typ[types.UntypedNil] {
+						ctx.handleCodeErrorf(&pos, "multiple nil cases in type switch (first at %v)", ctx.Position(other.Pos()))
+					} else {
+						ctx.handleCodeErrorf(&pos, "duplicate case %s in type switch\n\tprevious case at %v", T, ctx.Position(other.Pos()))
+					}
+				}
+			}
+			if !haserr {
+				seen[T] = citem
+			}
+		}
+		if c.List == nil {
+			if firstDefault != nil {
+				pos := ctx.Position(c.Pos())
+				ctx.handleCodeErrorf(&pos, "multiple defaults in type switch (first at %v)", ctx.Position(firstDefault.Pos()))
+			} else {
+				firstDefault = c
+			}
 		}
 		cb.TypeCase(len(c.List)) // TypeCase(0) means default case
 		compileStmts(ctx, c.Body)


Test patch:
diff --git a/cl/error_msg_test.go b/cl/error_msg_test.go
index affef670..b4ee9bcb 100644
--- a/cl/error_msg_test.go
+++ b/cl/error_msg_test.go
@@ -708,3 +708,35 @@ switch n {
 	default:
 }`)
 }
+
+func TestErrTypeSwitchDuplicate(t *testing.T) {
+	codeErrorTest(t, `./bar.gop:4:7: duplicate case int in type switch
+	previous case at ./bar.gop:3:7
+./bar.gop:5:7: duplicate case int in type switch
+	previous case at ./bar.gop:3:7`,
+		`var n interface{} = 100
+switch n.(type) {
+	case int:
+	case int:
+	case int:
+}
+`)
+	codeErrorTest(t, `./bar.gop:4:7: multiple nil cases in type switch (first at ./bar.gop:3:7)
+./bar.gop:5:7: multiple nil cases in type switch (first at ./bar.gop:3:7)`,
+		`var n interface{} = 100
+switch n.(type) {
+	case nil:
+	case nil:
+	case nil:
+}
+`)
+	codeErrorTest(t, `./bar.gop:4:2: multiple defaults in type switch (first at ./bar.gop:3:2)
+./bar.gop:5:2: multiple defaults in type switch (first at ./bar.gop:3:2)`,
+		`var n interface{} = 100
+switch n.(type) {
+	default:
+	default:
+	default:
+}
+`)
+}
Repository: goplus/gop
Pull request #946 (2021-11-26 09:06:49)

cl: support print/println cmd no params call
fix https://github.com/goplus/gop/issues/937


Patch:
diff --git a/cl/expr.go b/cl/expr.go
index 3ae52203..5c7f0f5f 100644
--- a/cl/expr.go
+++ b/cl/expr.go
@@ -115,7 +115,9 @@ func compileIdent(ctx *blockCtx, ident *ast.Ident, flags int) *gox.PkgRef {
 
 	// universe object
 	if (flags&clIdentAllowBuiltin) == 0 && isBuiltin(o) {
-		panic(ctx.newCodeErrorf(ident.Pos(), "use of builtin %s not in function call", name))
+		if !(fvalue && (name == "print" || name == "println")) {
+			panic(ctx.newCodeErrorf(ident.Pos(), "use of builtin %s not in function call", name))
+		}
 	}
 	if obj := ctx.pkg.Builtin().TryRef(name); obj != nil {
 		o = obj
@@ -371,6 +373,14 @@ func compilePkgRef(ctx *blockCtx, at *gox.PkgRef, x *ast.Ident, flags int) bool
 	return false
 }
 
+func isBuiltinCall(ctx *blockCtx, expr ast.Expr) bool {
+	if ident, ok := expr.(*ast.Ident); ok {
+		_, builtin := lookupType(ctx, ident.Name)
+		return isBuiltin(builtin)
+	}
+	return false
+}
+
 func isFunc(typ types.Type) bool {
 	switch typ.(type) {
 	case *types.Signature:
diff --git a/cl/stmt.go b/cl/stmt.go
index d79f5c7c..fe25ef09 100644
--- a/cl/stmt.go
+++ b/cl/stmt.go
@@ -82,7 +82,7 @@ func compileStmt(ctx *blockCtx, stmt ast.Stmt) {
 	switch v := stmt.(type) {
 	case *ast.ExprStmt:
 		compileExpr(ctx, v.X)
-		if canAutoCall(v.X) && isFunc(ctx.cb.InternalStack().Get(-1).Type) {
+		if (canAutoCall(v.X) && isFunc(ctx.cb.InternalStack().Get(-1).Type)) || isBuiltinCall(ctx, v.X) {
 			ctx.cb.Call(0)
 		}
 	case *ast.AssignStmt:


Test patch:
diff --git a/cl/compile_test.go b/cl/compile_test.go
index 78413739..85ef0c5a 100644
--- a/cl/compile_test.go
+++ b/cl/compile_test.go
@@ -3446,3 +3446,18 @@ func (p *Point) String() string {
 }
 `)
 }
+
+func TestCallPrint(t *testing.T) {
+	gopClTest(t, `
+print
+println
+`, `package main
+
+import fmt "fmt"
+
+func main() {
+	fmt.Print()
+	fmt.Println()
+}
+`)
+}
Repository: goplus/gop
Pull request #949 (2021-11-26 15:12:00)

Revert "cl: support print/println cmd no params call"
Reverts goplus/gop#946


Patch:
diff --git a/cl/expr.go b/cl/expr.go
index bffa172f..67551bce 100644
--- a/cl/expr.go
+++ b/cl/expr.go
@@ -115,9 +115,7 @@ func compileIdent(ctx *blockCtx, ident *ast.Ident, flags int) *gox.PkgRef {
 
 	// universe object
 	if (flags&clIdentAllowBuiltin) == 0 && isBuiltin(o) {
-		if !(fvalue && (name == "print" || name == "println")) {
-			panic(ctx.newCodeErrorf(ident.Pos(), "use of builtin %s not in function call", name))
-		}
+		panic(ctx.newCodeErrorf(ident.Pos(), "use of builtin %s not in function call", name))
 	}
 	if obj := ctx.pkg.Builtin().TryRef(name); obj != nil {
 		o = obj
@@ -373,14 +371,6 @@ func compilePkgRef(ctx *blockCtx, at *gox.PkgRef, x *ast.Ident, flags int) bool
 	return false
 }
 
-func isBuiltinCall(ctx *blockCtx, expr ast.Expr) bool {
-	if ident, ok := expr.(*ast.Ident); ok {
-		_, builtin := lookupType(ctx, ident.Name)
-		return isBuiltin(builtin)
-	}
-	return false
-}
-
 func isFunc(typ types.Type) bool {
 	switch typ.(type) {
 	case *types.Signature:
diff --git a/cl/stmt.go b/cl/stmt.go
index dcd77c1e..845f4498 100644
--- a/cl/stmt.go
+++ b/cl/stmt.go
@@ -82,7 +82,7 @@ func compileStmt(ctx *blockCtx, stmt ast.Stmt) {
 	switch v := stmt.(type) {
 	case *ast.ExprStmt:
 		compileExpr(ctx, v.X)
-		if (canAutoCall(v.X) && isFunc(ctx.cb.InternalStack().Get(-1).Type)) || isBuiltinCall(ctx, v.X) {
+		if canAutoCall(v.X) && isFunc(ctx.cb.InternalStack().Get(-1).Type) {
 			ctx.cb.Call(0)
 		}
 	case *ast.AssignStmt:


Test patch:
diff --git a/cl/compile_test.go b/cl/compile_test.go
index 7942f6fa..299a24c4 100644
--- a/cl/compile_test.go
+++ b/cl/compile_test.go
@@ -3475,18 +3475,3 @@ func (p *Point) String() string {
 }
 `)
 }
-
-func TestCallPrint(t *testing.T) {
-	gopClTest(t, `
-print
-println
-`, `package main
-
-import fmt "fmt"
-
-func main() {
-	fmt.Print()
-	fmt.Println()
-}
-`)
-}
Repository: goplus/gop
Pull request #950 (2021-11-26 23:39:49)

cl: fix print/println cmd no params call
fix https://github.com/goplus/gop/issues/937


Patch:
diff --git a/cl/stmt.go b/cl/stmt.go
index 845f4498..08732bec 100644
--- a/cl/stmt.go
+++ b/cl/stmt.go
@@ -81,9 +81,14 @@ func compileStmt(ctx *blockCtx, stmt ast.Stmt) {
 	commentStmt(ctx, stmt)
 	switch v := stmt.(type) {
 	case *ast.ExprStmt:
-		compileExpr(ctx, v.X)
-		if canAutoCall(v.X) && isFunc(ctx.cb.InternalStack().Get(-1).Type) {
+		if obj, ok := isBuiltinAutoCall(ctx, v.X); ok {
+			ctx.cb.Val(obj)
 			ctx.cb.Call(0)
+		} else {
+			compileExpr(ctx, v.X)
+			if canAutoCall(v.X) && isFunc(ctx.cb.InternalStack().Get(-1).Type) {
+				ctx.cb.Call(0)
+			}
 		}
 	case *ast.AssignStmt:
 		compileAssignStmt(ctx, v)
@@ -142,6 +147,19 @@ retry:
 	return false
 }
 
+func isBuiltinAutoCall(ctx *blockCtx, expr ast.Expr) (types.Object, bool) {
+	if ident, ok := expr.(*ast.Ident); ok {
+		switch ident.Name {
+		case "print", "println":
+			_, builtin := lookupType(ctx, ident.Name)
+			if isBuiltin(builtin) {
+				return builtin, true
+			}
+		}
+	}
+	return nil, false
+}
+
 func compileReturnStmt(ctx *blockCtx, expr *ast.ReturnStmt) {
 	var n = -1
 	var results *types.Tuple


Test patch:
diff --git a/cl/compile_test.go b/cl/compile_test.go
index 299a24c4..a1d9c99c 100644
--- a/cl/compile_test.go
+++ b/cl/compile_test.go
@@ -3475,3 +3475,26 @@ func (p *Point) String() string {
 }
 `)
 }
+
+func TestCallPrintln(t *testing.T) {
+	gopClTest(t, `
+print
+print "hello"
+print("hello")
+println
+println "hello"
+println("hello")
+`, `package main
+
+import fmt "fmt"
+
+func main() {
+	fmt.Print()
+	fmt.Print("hello")
+	fmt.Print("hello")
+	fmt.Println()
+	fmt.Println("hello")
+	fmt.Println("hello")
+}
+`)
+}
Repository: goplus/gop
Pull request #976 (2021-11-29 13:47:09)

Correct renamed variables


Patch:
diff --git a/env/path.go b/env/path.go
index f3919a1e..7d72e7c8 100644
--- a/env/path.go
+++ b/env/path.go
@@ -65,7 +65,7 @@ func findGopRoot() (string, error) {
 		}
 	}
 
-	// check build.GopRoot, if it is valid, use it
+	// check defaultGopRoot, if it is valid, use it
 	if defaultGopRoot != "" && isValidGopRoot(defaultGopRoot) {
 		return defaultGopRoot, nil
 	}


Test patch:
diff --git a/env/path_test.go b/env/path_test.go
index aa8bf387..f9e162ec 100644
--- a/env/path_test.go
+++ b/env/path_test.go
@@ -184,7 +184,7 @@ func TestFindGoModFileInGopRoot(t *testing.T) {
 		findGoModFile(src)
 	})
 
-	t.Run("set build.GopRoot to a valid goproot path", func(tt *testing.T) {
+	t.Run("set defaultGopRoot to a valid goproot path", func(tt *testing.T) {
 		tt.Cleanup(cleanupAll)
 		_, src, gopRoot := makeTestDir(tt)
 
@@ -192,11 +192,11 @@ func TestFindGoModFileInGopRoot(t *testing.T) {
 		modfile, noCacheFile, err := findGoModFile(src)
 
 		if err != nil || modfile != filepath.Join(gopRoot, "go.mod") || !noCacheFile {
-			tt.Fatal("should found go.mod in the dir of build.GopRoot, got:", modfile, noCacheFile, err)
+			tt.Fatal("should found go.mod in the dir of defaultGopRoot, got:", modfile, noCacheFile, err)
 		}
 	})
 
-	t.Run("set build.GopRoot to an invalid path", func(tt *testing.T) {
+	t.Run("set defaultGopRoot to an invalid path", func(tt *testing.T) {
 		tt.Cleanup(cleanupAll)
 		root, src, _ := makeTestDir(tt)
 		invalidGopRoot := filepath.Join(root, "invalid_goproot")
@@ -206,7 +206,7 @@ func TestFindGoModFileInGopRoot(t *testing.T) {
 			modfile, noCacheFile, err := findGoModFile(src)
 
 			if err == nil || noCacheFile || modfile != "" {
-				tt.Fatal("should not found go.mod when build.GopRoot isn't exists, got:", modfile, noCacheFile, err)
+				tt.Fatal("should not found go.mod when defaultGopRoot isn't exists, got:", modfile, noCacheFile, err)
 			}
 		}
 
@@ -215,7 +215,7 @@ func TestFindGoModFileInGopRoot(t *testing.T) {
 			modfile, noCacheFile, err := findGoModFile(src)
 
 			if err == nil || noCacheFile || modfile != "" {
-				tt.Fatal("should not found go.mod when build.GopRoot isn't an valid gop root dir, got:", modfile, noCacheFile, err)
+				tt.Fatal("should not found go.mod when defaultGopRoot isn't an valid gop root dir, got:", modfile, noCacheFile, err)
 			}
 		}
 	})
@@ -314,7 +314,7 @@ func TestFindGoModFileInGopRoot(t *testing.T) {
 			}
 		})
 
-		tt.Run("set build.GopRoot to an invalid gop root dir", func(tt *testing.T) {
+		tt.Run("set defaultGopRoot to an invalid gop root dir", func(tt *testing.T) {
 			gopRoot := filepath.Join(root, "gop")
 
 			defaultGopRoot = filepath.Join(root, "invalid_goproot")
@@ -325,7 +325,7 @@ func TestFindGoModFileInGopRoot(t *testing.T) {
 			}
 		})
 
-		tt.Run("set build.GopRoot to a valid gop root dir", func(tt *testing.T) {
+		tt.Run("set defaultGopRoot to a valid gop root dir", func(tt *testing.T) {
 			newGopRoot := filepath.Join(root, "new_gop_root")
 			makeValidGopRoot(newGopRoot)