Skip to content

v3: preserve map guards in return match lowering - #28175

Merged
medvednikov merged 1 commit into
masterfrom
fix-v3-return-match-map-guard
Aug 26, 2026
Merged

v3: preserve map guards in return match lowering#28175
medvednikov merged 1 commit into
masterfrom
fix-v3-return-match-map-guard

Conversation

@medvednikov

Copy link
Copy Markdown
Member

What changed

  • Preserve map lookup presence checks when return-if chains are created while lowering return-match expressions.
  • Bind the typed map value only after map__get_check succeeds.
  • Add regression coverage for both the first guard and a chained else-if guard.

Why

The previous return-match lowering transformed a guarded map index into a plain map__get value before C generation. The remaining guard then treated FastcLocal and string values as optional wrappers and emitted invalid .ok and .value field accesses, producing 11 C compiler errors during V3 self-hosting.

Tests

  • ./vnew -run-only test_return_match_map_lookup_guard_keeps_presence_check vlib/v3/tests/review_transform_regressions_test.v
  • ./vnew -silent test vlib/v3/transform/
  • cd vlib/v3 && ../../vnew -gc none -prealloc -o v3 v3.v && ./v3 -nocache -building-v -o v4 v3.v

@medvednikov
medvednikov merged commit 2762d86 into master Aug 26, 2026
4 of 14 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.

1 participant