Skip to content

hrw4u: Fix u4wrh cidr() emitting 1-arg form missing IPv6 bits#13205

Open
Clendenin wants to merge 1 commit into
apache:masterfrom
Clendenin:bugfix/u4wrh-cidr-arity
Open

hrw4u: Fix u4wrh cidr() emitting 1-arg form missing IPv6 bits#13205
Clendenin wants to merge 1 commit into
apache:masterfrom
Clendenin:bugfix/u4wrh-cidr-arity

Conversation

@Clendenin
Copy link
Copy Markdown
Contributor

Summary

HRW %{CIDR:a} supplies only IPv4 bits and relies on implicit IPv6 defaults,
while Prism cidr() requires both ipv4_bits and ipv6_bits. When u4wrh sees
the single value form, pad with the canonical HRW IPv6 default (48) so the
emitted Prism has valid arity and round-trips stably.

This change also extends the CIDR reverse branch to handle the bare %{CIDR}
no-payload form, padding to cidr(24, 48) using HRW's canonical defaults so
the forward round-trip satisfies the 2-arg signature.

HRW %{CIDR:a} supplies only IPv4 bits and relies on implicit IPv6 defaults,
while HRW4U cidr() requires both ipv4_bits and ipv6_bits. When u4wrh sees
the single value form, pad with the canonical HRW IPv6 default (48) so the
emitted HRW4U has valid arity and round-trips stably.

Extends the CIDR reverse branch to handle the bare %{CIDR} no-payload form,
padding to cidr(24, 48) using HRW's canonical defaults so the forward
round-trip satisfies the 2-arg signature.
@Clendenin Clendenin force-pushed the bugfix/u4wrh-cidr-arity branch from e54f88e to 8ad9807 Compare May 27, 2026 23:19
@zwoop zwoop requested a review from Copilot May 29, 2026 17:14
@zwoop zwoop self-requested a review May 29, 2026 17:15
@zwoop zwoop added the hrw4u label May 29, 2026
@zwoop zwoop removed this from ATS v11.0.x May 29, 2026
@zwoop zwoop added this to the 11.0.0 milestone May 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a u4wrh (reverse compiler) bug where HRW %{CIDR} and %{CIDR:N} forms produced HRW4U cidr() calls with too few arguments, violating the 2-arg requirement enforced by forward validation. The reverse path now pads to HRW's canonical defaults (v4=24, v6=48), restoring stable round-tripping.

Changes:

  • Add _pad_cidr_args helper and a CIDR-specific branch in InverseSymbolResolver.percent_to_ident_or_func to fill in defaults for missing IPv4/IPv6 bit values.
  • Add reverse-only test fixtures for bare %{CIDR}, single-arg %{CIDR:N}, and v6-only %{CIDR:,N} forms.
  • Mark new fixtures as u4wrh-only exceptions since forward emission always produces explicit two-arg %{CIDR:v4,v6}.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

File Description
tools/hrw4u/src/hrw_symbols.py Adds _pad_cidr_args and CIDR special case in reverse function tag handling.
tools/hrw4u/tests/data/conds/exceptions.txt Registers cidr-single and cidr-bare as u4wrh-only fixtures.
tools/hrw4u/tests/data/conds/cidr-single.{input,output,ast}.txt New fixture covering %{CIDR:16}, %{CIDR:24,64}, %{CIDR:,8} reverse cases.
tools/hrw4u/tests/data/conds/cidr-bare.{input,output,ast}.txt New fixture covering bare %{CIDR} reverse case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants