Skip to content

dyn: Use nil as default location instead of empty slice - #2742

Merged
denik merged 3 commits into
mainfrom
denik/nil-locations
Apr 22, 2025
Merged

dyn: Use nil as default location instead of empty slice#2742
denik merged 3 commits into
mainfrom
denik/nil-locations

Conversation

@denik

Copy link
Copy Markdown
Contributor

Why

@pietern

Copy link
Copy Markdown
Contributor

Is this complete? Could we enforce no use of []dyn.Location{} in a linter perhaps?

func TestMappingKeysValues(t *testing.T) {
// Configure mapping
var m dyn.Mapping
m.SetLoc("key1", []dyn.Location{}, dyn.V("foo"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There are other places in the code where we use []dyn.Location{}, should it be changed as well?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Updated all.

@denik
denikforce-pushed the denik/nil-locations branch from 3dfaf77 to 57c4e63CompareApril 22, 2025 12:10
@denik
deniktemporarily deployed to test-trigger-is April 22, 2025 12:10 — with GitHub Actions Inactive
@denik
denik requested a review from andrewnesterApril 22, 2025 12:13
@denik

Copy link
Copy Markdown
ContributorAuthor

Is this complete? Could we enforce no use of []dyn.Location{} in a linter perhaps?

I updated more places as returned by git grep -E '\[\]dyn.Location{}'.

Regarding linter, maybe we can adapt #2576 cc @anton-107 but I'd say it's out of scope here.

Once we get rid of dynassert, various test cases that currently ignore location would require exact location there, so it's not something that's untested.

Base automatically changed from denik/SetLoc to mainApril 22, 2025 14:41
@denik
denikforce-pushed the denik/nil-locations branch from 57c4e63 to 71c4e55CompareApril 22, 2025 14:59
@denik
deniktemporarily deployed to test-trigger-is April 22, 2025 14:59 — with GitHub Actions Inactive
@denik
denik enabled auto-merge April 22, 2025 14:59
@denik
deniktemporarily deployed to test-trigger-is April 22, 2025 15:00 — with GitHub Actions Inactive
@denik
denik added this pull request to the merge queueApr 22, 2025
Merged via the queue into main with commit 3cf1b24Apr 22, 2025
@denik
denik deleted the denik/nil-locations branch April 22, 2025 15:37
denik added a commit that referenced this pull request May 20, 2026
## Why
- This starts to matter once we replace dynassert with regular assert
#2737
- We agreed before to use nils consistently instead of empty slices.
Sign up for freeto 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.

3 participants

@denik@pietern@andrewnester