Skip to content

Commit

Permalink
Merge pull request #1314 from xushiwei/cmd
Browse files Browse the repository at this point in the history
fix #1312
  • Loading branch information
xushiwei committed Jul 1, 2022
2 parents aae2572 + 6a00e1f commit e0f975b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
1 change: 1 addition & 0 deletions parser/_testdata/cmdlinestyle5/cmd5.gop
@@ -0,0 +1 @@
println (1+2i)*2
41 changes: 41 additions & 0 deletions parser/_testdata/cmdlinestyle5/parser.expect
@@ -0,0 +1,41 @@
package main

file cmd5.gop
noEntrypoint
ast.FuncDecl:
Name:
ast.Ident:
Name: main
Type:
ast.FuncType:
Params:
ast.FieldList:
Body:
ast.BlockStmt:
List:
ast.ExprStmt:
X:
ast.CallExpr:
Fun:
ast.Ident:
Name: println
Args:
ast.BinaryExpr:
X:
ast.ParenExpr:
X:
ast.BinaryExpr:
X:
ast.BasicLit:
Kind: INT
Value: 1
Op: +
Y:
ast.BasicLit:
Kind: IMAG
Value: 2i
Op: *
Y:
ast.BasicLit:
Kind: INT
Value: 2
3 changes: 2 additions & 1 deletion parser/parser.go
Expand Up @@ -1896,7 +1896,8 @@ L:
if lhs {
p.resolve(x)
}
x = p.parseCallOrConversion(p.checkExprOrType(x), false)
isCmd := allowCmd && x.End() != p.pos // println ()
x = p.parseCallOrConversion(p.checkExprOrType(x), isCmd)
case token.LBRACE: // {
if allowCmd && x.End() != p.pos { // println {}
x = p.parseCallOrConversion(p.checkExprOrType(x), true)
Expand Down

0 comments on commit e0f975b

Please sign in to comment.