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

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

SuryaprakashBS opened this issue Dec 28, 2021 · 6 comments
Labels
NeedsFix
Milestone

Comments

@SuryaprakashBS
Copy link

@SuryaprakashBS SuryaprakashBS commented Dec 28, 2021

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 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 label Dec 28, 2021
@thanm
Copy link
Contributor

@thanm thanm commented Dec 28, 2021

@randall77 @griesemer per owners.

@randall77
Copy link
Contributor

@randall77 randall77 commented Dec 28, 2021

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

@griesemer
Copy link
Contributor

@griesemer griesemer commented Dec 28, 2021

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 and removed NeedsDecision labels Dec 28, 2021
@griesemer griesemer added this to the Go1.18 milestone Dec 28, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented Jan 4, 2022

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

@gopherbot
Copy link

@gopherbot gopherbot commented Jan 4, 2022

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix
Projects
None yet
Development

No branches or pull requests

6 participants