Repository: goplus/gop
Pull request #1707 (2024-02-05 04:57:09)

 [wip] scanner: fix ... insertSemi
fix https://play.goplus.org/p/2oa58nQsjIN

codecov[bot]: ## [Codecov](https://app.codecov.io/gh/goplus/gop/pull/1707?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goplus) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Comparison is base [(`1172ae4`)](https://app.codecov.io/gh/goplus/gop/commit/1172ae40ce436f0ba995ba87cf3984f0bef757e5?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goplus) 91.92% compared to head [(`e28d2c8`)](https://app.codecov.io/gh/goplus/gop/pull/1707?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goplus) 92.53%.
> Report is 2 commits behind head on main.


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


```diff
@@            Coverage Diff             @@
##             main    #1707      +/-   ##
==========================================
+ Coverage   91.92%   92.53%   +0.61%     
==========================================
  Files          39       38       -1     
  Lines       10775     8870    -1905     
==========================================
- Hits         9905     8208    -1697     
+ Misses        704      496     -208     
  Partials      166      166              
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/goplus/gop/pull/1707?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goplus).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goplus).


Patch:
diff --git a/parser/parser.go b/parser/parser.go
index 1c011e92..9437bfec 100644
--- a/parser/parser.go
+++ b/parser/parser.go
@@ -466,8 +466,8 @@ func (p *parser) expectClosing(tok token.Token, context string) token.Pos {
 }
 
 func (p *parser) expectSemi() {
-	// semicolon is optional before a closing ')' or '}' or EOF
-	if p.tok != token.RPAREN && p.tok != token.RBRACE && p.tok != token.EOF {
+	// semicolon is optional before a closing ')' or '}'
+	if p.tok != token.RPAREN && p.tok != token.RBRACE {
 		switch p.tok {
 		case token.COMMA:
 			// permit a ',' instead of a ';' but complain
diff --git a/scanner/scanner.go b/scanner/scanner.go
index 08189102..c2f0eb32 100644
--- a/scanner/scanner.go
+++ b/scanner/scanner.go
@@ -879,6 +879,7 @@ scanAgain:
 			if s.ch == '.' && s.peek() == '.' {
 				s.next()
 				s.next() // consume last '.'
+				insertSemi = true
 				tok = token.ELLIPSIS
 			}
 		case ',':


Test patch:
diff --git a/parser/_testdata/printvariadic/parser.expect b/parser/_testdata/printvariadic/parser.expect
index 61658c49..ae693de7 100644
--- a/parser/_testdata/printvariadic/parser.expect
+++ b/parser/_testdata/printvariadic/parser.expect
@@ -22,3 +22,12 @@ ast.FuncDecl:
               Args:
                 ast.Ident:
                   Name: x
+        ast.ExprStmt:
+          X:
+            ast.CallExpr:
+              Fun:
+                ast.Ident:
+                  Name: println
+              Args:
+                ast.Ident:
+                  Name: y
diff --git a/parser/_testdata/printvariadic/printv.gop b/parser/_testdata/printvariadic/printv.gop
index 72d734b3..6177ac88 100644
--- a/parser/_testdata/printvariadic/printv.gop
+++ b/parser/_testdata/printvariadic/printv.gop
@@ -1,1 +1,2 @@
 println x...
+println y...