Skip to content

lib.enum: privatize internal attributes in EnumView/FlagView #1424

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

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

whitequark
Copy link
Member

Before this commit, public names enum and target were not usable as enumeration member or method names. This was unintentional and our policy is to not reserve public names where they may clash with names defined in downstream code.

This commit makes them a private name (__enum, etc). This was chosen instead of a sunder name (_amaranth_enum_, etc) because there is a 1:1 correspondence between the attribute and a ValueCastable method:

  • shape() -> __enum
  • as_value() -> __target

@whitequark whitequark added this to the 0.6 milestone Jun 27, 2024
@whitequark whitequark enabled auto-merge June 27, 2024 14:48
Copy link

codecov bot commented Jun 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.13%. Comparing base (42d90a3) to head (fe1f5fd).
Report is 1 commits behind head on main.

Current head fe1f5fd differs from pull request most recent head 915eaa5

Please upload reports for the commit 915eaa5 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1424      +/-   ##
==========================================
+ Coverage   90.83%   91.13%   +0.29%     
==========================================
  Files          43       43              
  Lines       10946    10963      +17     
  Branches     2305     2656     +351     
==========================================
+ Hits         9943     9991      +48     
+ Misses        830      801      -29     
+ Partials      173      171       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Before this commit, public names `enum` and `target` were not usable as
enumeration member or method names. This was unintentional and our
policy is to not reserve public names where they may clash with names
defined in downstream code.

This commit makes them a private name (`__enum`, etc). This was chosen
instead of a sunder name (`_amaranth_enum_`, etc) because there is
a 1:1 correspondence between the attribute and a `ValueCastable` method:
* `shape()` -> `__enum`
* `as_value()` -> `__target`
@whitequark whitequark force-pushed the enum-view-stray-names branch from fe1f5fd to 915eaa5 Compare June 27, 2024 15:01
@whitequark whitequark added this pull request to the merge queue Jun 27, 2024
Merged via the queue into amaranth-lang:main with commit 8542252 Jun 27, 2024
19 of 20 checks passed
@whitequark whitequark deleted the enum-view-stray-names branch June 27, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

1 participant