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

internal compiler error #1606

Closed
gopherbot opened this Issue Mar 13, 2011 · 6 comments

Comments

Projects
None yet
3 participants
@gopherbot

gopherbot commented Mar 13, 2011

by remigius.gieben:

1. What is a short input program that triggers the error?
func New(i int) RR {
        var rr RR
        mk, known := rr_mk[i]
        if !known {
                rr = new(RR_RFC3597)
        } else {
                rr = mk()
        }   

        switch t := rr.(type) {
//        case *RR_TSIG:  // This works
        case TypeTSIG:    // this triggers the bug (TypeTSIG is just an int)
                t.Hdr = RR_Header{Ttl: 0, Class: ClassANY, Rrtype: uint16(i)}
                t.Fudge = 300 
        }   
        return rr
}


2. What is the full compiler output?
defaultlit [2b1b5cf4e330]
.   NAME-t G1170 u(1) a(1) g(1170) l(3775) x(-1000000000) class(2) f(1) tc(1) ideal
new.go:12: TypeTSIG is not a type
new.go:15: internal compiler error: defaultlit


3. What version of the compiler are you using?  (Run it with the -V flag.)
6g version release.2011-03-07.1 7666
@adg

This comment has been minimized.

Contributor

adg commented Mar 14, 2011

Comment 1:

Labels changed: added compilerbug.

Owner changed to r...@golang.org.

Status changed to Accepted.

@gopherbot

This comment has been minimized.

gopherbot commented May 5, 2011

Comment 2 by lstoakes:

I don't seem to be able to reproduce this - do you have more code available, as the
example is relying on declarations not shown?
Thanks
@rsc

This comment has been minimized.

Contributor

rsc commented May 6, 2011

Comment 3:

package main
var T *struct {
    y int
}
func main() {
    var x interface{}
    switch t := x.(type) {
    case T:
        t.x = 1
    }
}
I think the bug was caused by the fact that after the "not a type" error
we don't clear the type associated with t, so it ends up having the
same type as T, and then that gets used for additional error messages.
@gopherbot

This comment has been minimized.

gopherbot commented May 9, 2011

Comment 4 by lstoakes:

That doesn't repro the precise bug reported for me - I get:-
repro.go:9: T is not a type
repro.go:11: t.x undefined (type *struct { y int } has no field or method x)
Rather than any internal compiler error. It is strange, however, that though T isn't a
type, it then acts as if t is of that type in the case block, as you say it seems to be
treating t as T's type, despite T not being a type itself.
However, if we go ahead and just use a straight-up literal we get the following internal
compiler error:-
package main
func main() {
    var x interface{}
    switch t := x.(type) {
    case 0:
        t.x = 1
    }
 
}
defaultlit [9aa5f40]
.   NAME-t G97 u(1) a(1) g(97) l(6) x(-1000000000) class(2) f(1) tc(1) ideal
repro.go:5: 0 is not a type
repro.go:7: internal compiler error: defaultlit
Am investigating.
@gopherbot

This comment has been minimized.

gopherbot commented May 9, 2011

Comment 5 by lstoakes:

That doesn't seem to repro the internal compiler error for me, instead I get:-
repro.go:9: T is not a type
repro.go:11: t.x undefined (type *struct { y int } has no field or method x)
Rather than any internal compiler error. It is strange, however, that as you say it
seems to be assigning t T's type, despite T not being a type itself.
However, if we go ahead and just use a straight-up literal we get the following internal
compiler error:-
package main
func main() {
    var x interface{}
    switch t := x.(type) {
    case 0:
        t.x = 1
    }
 
}
defaultlit [9aa5f40]
.   NAME-t G97 u(1) a(1) g(97) l(6) x(-1000000000) class(2) f(1) tc(1) ideal
repro.go:5: 0 is not a type
repro.go:7: internal compiler error: defaultlit
Am investigating.
@rsc

This comment has been minimized.

Contributor

rsc commented May 12, 2011

Comment 6:

This issue was closed by revision f58d911.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.