Skip to content

go/types: missing error on an edge-case with continue/break with labels #70974

Open
@mateusz834

Description

Once again, because i am poking around with go/types internals, i have spotted a bug in the type-checker.

The code below type-checks without any error:

package test

func test() {
outer:
	for range "aa" {
		break outer
	}

	for range "aa" {
		break outer
	}
}

This happens because lstmt:

lstmt = s

is assigned and never cleared, thus:

go/src/go/types/labels.go

Lines 234 to 236 in b9955f0

case *ast.BlockStmt:
blockBranches(lstmt, s.List)

is executed with a wrong label (for the second for statement).

CC @adonovan @griesemer

Metadata

Assignees

Labels

NeedsFixThe path to resolution is known, but the work has not been done.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions