Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: better error message for invalid for i,j,k := range #50372

Closed
SuryaprakashBS opened this issue Dec 28, 2021 · 6 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@SuryaprakashBS
Copy link

Does this issue reproduce with the latest release?

yes

What did you do?

package main

var map1 map[string]int

var map2 map[string]int

func main() {
    map1["a"] = 1
    map1["b"] = 2
    
    for i,j,k := range map1{
    	map2[k] = j
    } 	
}
// https://go.dev/play/p/UUnsd-FmrT2

What did you see?

./prog.go:15:14: internal compiler error: expected an error about map2[k]

@SuryaprakashBS SuryaprakashBS changed the title affected/package: Internal Compiler Error Dec 28, 2021
@ALTree
Copy link
Member

ALTree commented Dec 28, 2021

Thanks for reporting this. It triggers an internal compiler error on go1.17.5, but tip correctly gives an error:

invalid AST: invalid lhs in range clause

Since the program is invalid, this may not qualify for a fix in a 1.17 minor release.

@ALTree ALTree changed the title Internal Compiler Error cmd/compile: Internal Compiler Error on invalid for i,j,k := range Dec 28, 2021
@ALTree ALTree added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Dec 28, 2021
@thanm
Copy link
Contributor

thanm commented Dec 28, 2021

@randall77 @griesemer per owners.

@randall77
Copy link
Contributor

I agree with @ALTree , I don't think there's anything to fix here.

@griesemer
Copy link
Contributor

The error message here should be better: an "invalid AST" error is typically expected for ASTs that are created "manually" (not by the parser) and are incorrect.

I'm going to re-open this as a reminder to fix error message.

@griesemer griesemer changed the title cmd/compile: Internal Compiler Error on invalid for i,j,k := range cmd/compile: better error message for invalid for i,j,k := range Dec 28, 2021
@griesemer griesemer reopened this Dec 28, 2021
@griesemer griesemer self-assigned this Dec 28, 2021
@griesemer griesemer added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Dec 28, 2021
@griesemer griesemer added this to the Go1.18 milestone Dec 28, 2021
@gopherbot
Copy link

Change https://golang.org/cl/375255 mentions this issue: cmd/compile: better error message for range clause

@gopherbot
Copy link

Change https://golang.org/cl/375475 mentions this issue: cmd/compile: better error message for invalid range clause

jproberts pushed a commit to jproberts/go that referenced this issue Jun 21, 2022
…lause

Fixes golang#50372.

Change-Id: I8e4c0020dae42744cce016433e398e0b884bb044
Reviewed-on: https://go-review.googlesource.com/c/go/+/375475
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
@golang golang locked and limited conversation to collaborators Jun 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants