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

agen PLUS #1710

Closed
gopherbot opened this issue Apr 16, 2011 · 7 comments
Closed

agen PLUS #1710

gopherbot opened this issue Apr 16, 2011 · 7 comments

Comments

@gopherbot
Copy link
Contributor

by Confunctionist:

1. What is a short input program that triggers the error?

package main

import "fmt"

const ( CR  = byte(13)
        LF  = byte(10)
        SPACE   = " "
)

func main() {

    fun := make([]byte,100)
    pos := 0
    for i := 0; i<10; i++{
        fun[pos] = byte(pos)
        pos++
    }
    fun[pos] = CR
    pos++
    fun[pos] = LF
    pos++

    str := ""
    for _, v := range fun {
        if v == CR {
            fmt.Printf(str)
        } else if v == LF {
            str = ""
        } else {
            str =+ string(v)
        }
    }

}


2. What is the full compiler output?

BUG.go line 30: internal compiler error: agen PLUS

3. What version of the compiler are you using?  (Run it with the -V flag.) 2011.03.7.1
7666

Attachments:

  1. BUG.go (413 bytes)
@davecheney
Copy link
Contributor

Comment 1:

FWIW, under 6g (I believe the original report was under 8g) the compiler is a little
more forthcoming
% 6g 1710.go 
1710.go:31: internal compiler error: agen: unknown op PLUS u(100) l(31) x(-1000000000)
tc(1) string

@davecheney
Copy link
Contributor

Comment 2:

Ah, ha
Here is the smallest possible program that will trigger the error
package main
func main() {
    str := ""
    for _, v := range make([]byte, 100) {
        str =+ string(v)
    }
    _ = str
}
% 6g 1710.go 
1710.go:6: internal compiler error: agen: unknown op PLUS u(100) l(6) x(-1000000000)
tc(1) string
however, if we gofmt that program, we get this
package main
func main() {
        str := ""
        for _, v := range make([]byte, 100) {
                str = +string(v)
        }
        _ = str
}
which reveals the that this isn't a compiler error, but a syntax checking error, as the
correct syntax for appending to strings is +=, no =+

@davecheney
Copy link
Contributor

Comment 3:

Ah, ha
Here is the smallest possible program that will trigger the error
package main
func main() {
    str := ""
    for _, v := range make([]byte, 100) {
        str =+ string(v)
    }
    _ = str
}
% 6g 1710.go 
1710.go:6: internal compiler error: agen: unknown op PLUS u(100) l(6) x(-1000000000)
tc(1) string
however, if we gofmt that program, we get this
package main
func main() {
        str := ""
        for _, v := range make([]byte, 100) {
                str = +string(v)
        }
        _ = str
}
which reveals the that this isn't a compiler error, but a syntax checking error, as the
correct syntax for appending to strings is +=, not =+.
http://golang.org/doc/go_spec.html#Arithmetic_operators

@rsc
Copy link
Contributor

rsc commented Apr 16, 2011

Comment 4:

You went and ruined the surprise.  :-(

@rsc
Copy link
Contributor

rsc commented Apr 16, 2011

Comment 5:

The fix should be easy: update the appropriate
table and add a test case.

Owner changed to @rsc.

Status changed to HelpWanted.

@davecheney
Copy link
Contributor

Comment 6:

> You went and ruined the surprise.  :-(
Aww shucks, sorry.

@rsc
Copy link
Contributor

rsc commented Apr 20, 2011

Comment 7:

This issue was closed by revision ec735c4.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
This issue was closed.
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

3 participants