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

Support calling pointer-receiver methods on struct fields #5

Open
tchajed opened this issue May 28, 2020 · 1 comment
Open

Support calling pointer-receiver methods on struct fields #5

tchajed opened this issue May 28, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@tchajed
Copy link
Collaborator

tchajed commented May 28, 2020

Right now we write code like

type foo struct {
    bar *Bar
}

func (f *foo) UseBar() {
    f.bar.DoSomething()
}

This results in double dereferencing - once to get the pointer bar and another within DoSomething() to access the fields of Bar.

Idiomatic Go would use bar Bar and then call pointer methods through the foo pointer. In GooseLang we already support constructing the pointer using a location offset, but goose doesn't emit code that takes advantage of this. See failing_testFooBarMutation for an example of what we'd like to support.

Implementing this probably requires some refactoring of the address-of code, to factor out all the code that computes pointers.

@tchajed tchajed added the enhancement New feature or request label May 28, 2020
@RalfJung
Copy link
Collaborator

From the title this sounds like a duplicate of #1?

tchajed pushed a commit that referenced this issue Jul 17, 2024
Fix bug with slice + integer literals; also fix bats tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants