Skip to content

feat!: narrow unions with UnionAs and name member lists Types - #7

Merged
enilsen16 merged 27 commits into
mainfrom
feat/union-as
Oct 22, 2026
Merged

enilsen16 merged 27 commits into
mainfrom
feat/union-as

Conversation

@enilsen16

@enilsen16 enilsen16 commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #6.

Summary

  • UnionAs[T](u) returns the union's member as an ID[T]. It returns false when the union holds another type or is zero. A caller can then narrow a union without a type switch, which replaces umbrella's to_fan_actor_id-style helpers.
  • UnionDefiner.Members() is now Types(), to match the Elixir use Trogon.UnionObjectId, types: [...]. MemberOf[T]() keeps its name, because TypeOf reads like reflect.TypeOf. This is a breaking change before v1.

Tests

TestUnionAs covers the matching member, another member, and the zero union. The existing union tests use the new names. CI runs only on PRs to main. Locally, go test -race, go vet and golangci-lint pass.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d36dc249-5114-4887-9107-69401982e1c2
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: Erik Nilsen <enilsen16@live.com>
…options

Signed-off-by: Erik Nilsen <enilsen16@live.com>
…ition

Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
…options

Signed-off-by: Erik Nilsen <enilsen16@live.com>

# Conflicts:
#	objectid_test.go
…d-checks

Signed-off-by: Erik Nilsen <enilsen16@live.com>

# Conflicts:
#	objectid.go
#	objectidproto/objectidproto.go
#	objectidproto/objectidproto_test.go
…n errors

Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
…-options

Signed-off-by: Erik Nilsen <enilsen16@live.com>

# Conflicts:
#	objectid.go
#	objectid_test.go
Signed-off-by: Erik Nilsen <enilsen16@live.com>
…-options

Signed-off-by: Erik Nilsen <enilsen16@live.com>

# Conflicts:
#	objectid.go
#	objectid_test.go
…d-checks

Signed-off-by: Erik Nilsen <enilsen16@live.com>

# Conflicts:
#	objectid.go
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Signed-off-by: Erik Nilsen <enilsen16@live.com>
Base automatically changed from feat/objectidtest to main October 22, 2026 16:20
Signed-off-by: Erik Nilsen <enilsen16@live.com>
@enilsen16
enilsen16 marked this pull request as ready for review October 22, 2026 16:28
@enilsen16
enilsen16 merged commit 91b78b0 into main Oct 22, 2026
3 checks passed
@enilsen16
enilsen16 deleted the feat/union-as branch October 22, 2026 16:31
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