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

struct arithmetic foul up #807

Closed
rogpeppe opened this issue May 24, 2010 · 2 comments
Closed

struct arithmetic foul up #807

rogpeppe opened this issue May 24, 2010 · 2 comments

Comments

@rogpeppe
Copy link
Contributor

1. What is a short input program that triggers the error?
// should print {0 300} but prints {0 -500} instead.
// changing Bbox to a value method fixes it. as does splitting
// the calculation up.

package main

import (
    "exp/draw"
    "fmt"
)

type Obj struct {
    bbox draw.Rectangle
}

func (o *Obj) Bbox() draw.Rectangle {
    return o.bbox
}

func main() {
    obj := &Obj{draw.Rect(800, 0, 0, 0)}
    p := draw.Pt(800, 300)
    fmt.Printf("%v\n", calc(obj, p))
}


func calc(obj *Obj, p draw.Point) draw.Point {
    return p.Sub(obj.Bbox().Min)
}



2. What is the full compiler output?
it compiles ok.

3. What version of the compiler are you using?  (Run it with the -V flag.)
8g version 5516+
@rsc
Copy link
Contributor

rsc commented May 24, 2010

Comment 1:

Labels changed: added priority-medium, compilerbug.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented May 24, 2010

Comment 2:

This issue was closed by revision 9fc9246.

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.
Projects
None yet
Development

No branches or pull requests

3 participants