aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/compile/internal/gc/lex.go1
-rw-r--r--src/cmd/compile/internal/gc/parser.go7
-rw-r--r--test/fixedbugs/issue13415.go19
3 files changed, 23 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/gc/lex.go b/src/cmd/compile/internal/gc/lex.go
index 6e8745caa5..55ba2ed3f4 100644
--- a/src/cmd/compile/internal/gc/lex.go
+++ b/src/cmd/compile/internal/gc/lex.go
@@ -1253,7 +1253,6 @@ l0:
c1 = getc()
if c1 == '=' {
c = int(LCOLAS)
- yylval.i = int(lexlineno)
goto lx
}
diff --git a/src/cmd/compile/internal/gc/parser.go b/src/cmd/compile/internal/gc/parser.go
index 22e3c4b7cf..20a1202d25 100644
--- a/src/cmd/compile/internal/gc/parser.go
+++ b/src/cmd/compile/internal/gc/parser.go
@@ -717,7 +717,7 @@ func (p *parser) simple_stmt(labelOk, rangeOk bool) *Node {
return stmt
case LCOLAS:
- line := lineno
+ lno := lineno
p.next()
if rangeOk && p.got(LRANGE) {
@@ -746,7 +746,7 @@ func (p *parser) simple_stmt(labelOk, rangeOk bool) *Node {
} // it's a colas, so must not re-use an oldname
return ts
}
- return colas(lhs, rhs, int32(line))
+ return colas(lhs, rhs, int32(lno))
default:
p.syntax_error("expecting := or = or comma")
@@ -849,6 +849,7 @@ func (p *parser) case_(tswitch *Node) *Node {
case LCOLAS:
// LCASE expr_or_type_list LCOLAS expr ':'
+ lno := lineno
p.next()
rhs := p.expr()
@@ -857,7 +858,7 @@ func (p *parser) case_(tswitch *Node) *Node {
// done in casebody()
markdcl() // matching popdcl in caseblock
stmt := Nod(OXCASE, nil, nil)
- stmt.List = list1(colas(cases, list1(rhs), int32(p.op)))
+ stmt.List = list1(colas(cases, list1(rhs), int32(lno)))
p.want(':') // consume ':' after declaring select cases for correct lineno
return stmt
diff --git a/test/fixedbugs/issue13415.go b/test/fixedbugs/issue13415.go
new file mode 100644
index 0000000000..989a1ed50f
--- /dev/null
+++ b/test/fixedbugs/issue13415.go
@@ -0,0 +1,19 @@
+// errorcheck
+
+// Copyright 2015 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Verify that error message regarding := appears on
+// correct line (and not on the line of the 2nd :=).
+
+package p
+
+func f() {
+ select {
+ case x, x := <-func() chan int { // ERROR "x repeated on left side of :="
+ c := make(chan int)
+ return c
+ }():
+ }
+}