Skip to content

fix for find references skipping fields set in struct literals that happen to be after a return statement - #1668

Merged
BradLewis merged 1 commit into
DanielGavin:masterfrom
xraxra:fix-ref-after-return
Sep 9, 2026
Merged

fix for find references skipping fields set in struct literals that happen to be after a return statement#1668
BradLewis merged 1 commit into
DanielGavin:masterfrom
xraxra:fix-ref-after-return

Conversation

@xraxra

@xraxra xraxra commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

I noticed sometimes find references wouldn't list things, it turns out if I'm using a struct literal and it's placed below a return statement in the file, it will be skipped

its due to the position_context.returns becoming stale as it walks over the file (since returns is checked before assign)

simple repro scenario:

package main

Config :: struct {
	width: int,
}

// when there is a proc with return anywhere earlier in the file,
// find references on a struct field is unable to see places where that field is set inside a struct literal
unrelated :: proc() {
	return
}

apply :: proc() {
	config: Config
	config = { 	// the struct/compound literal
		width = 1, // find references on 'width' will miss this line
	}
	config.width = 1 // but this one is found
}

…ing fields of struct literals from find references, only in cases where the struct literal is located later in the file (below a proc with return)

@BradLewis BradLewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@BradLewis
BradLewis merged commit 110e637 into DanielGavin:master Sep 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants