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: crash on package name used as value in constant declaration #15265

Closed
ericlagergren opened this issue Apr 12, 2016 · 7 comments
Closed
Milestone

Comments

@ericlagergren
Copy link
Contributor

This is seemingly low-priority. I only ran into this because of a typo but it threw me off for a second.

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?

    1.6

  2. What operating system and processor architecture are you using (go env)?

    GOOS=linux
    GOARCH=amd64

  3. What did you do?
    If possible, provide a recipe for reproducing the error.
    A complete runnable program is good.
    A link on play.golang.org is best.

    https://play.golang.org/p/M93SytJouJ

  4. What did you expect to see?

    An error message telling me that what I did was stupid.
    E.g.: "Cannot concatenate identifier 'fmt'"

  5. What did you see instead?

    A cryptic message

@bradfitz
Copy link
Contributor

Message is:

treecopy [0xc8201a8bd0]
.   PACK l(4) main.fmt
prog.go:8: internal compiler error: treecopy Name

@ericlagergren
Copy link
Contributor Author

@bradfitz Ah yes I should've added that to my original comment.

@bradfitz bradfitz changed the title cmd/compile: Better error message for invalid string concatenation cmd/compile: internal compiler error concatenating string literal and package identifier Apr 12, 2016
@bradfitz bradfitz added this to the Go1.7 milestone Apr 12, 2016
@davecheney
Copy link
Contributor

Ok, thus is something we should fix. This isn't a syntax error, that code
crashed the compiler.

On Wed, 13 Apr 2016, 08:52 Eric Lagergren, notifications@github.com wrote:

@bradfitz https://github.com/bradfitz Ah yes I should've added that to
my original comment.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#15265 (comment)

@ericlagergren
Copy link
Contributor Author

Additionally, it crashes with integer literals: https://play.golang.org/p/mztla8DYUz

And afaik anything else that is considered a constant expression.

@bradfitz Should the title be changed to reflect this affects both integer and string literals?

@mdempsky mdempsky changed the title cmd/compile: internal compiler error concatenating string literal and package identifier cmd/compile: crash on package name used as value in constant declaration Apr 12, 2016
@mdempsky
Copy link
Member

@ericlagergren Thanks for the report. Minimal repro:

package main
import "fmt"
const x = fmt

I think the fix is as simple as adding OPACK to case ONAME, OLITERAL, OTYPE: in treecopy.

@ALTree
Copy link
Member

ALTree commented Apr 12, 2016

Dup of #11361

@ianlancetaylor
Copy link
Contributor

Closing as dup.

@golang golang locked and limited conversation to collaborators Apr 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants