Skip to content

Report S0015 split-port errors at the interface field's declaration#1053

Open
nanavati wants to merge 1 commit into
B-Lang-org:mainfrom
nanavati:s0015-field-position
Open

Report S0015 split-port errors at the interface field's declaration#1053
nanavati wants to merge 1 commit into
B-Lang-org:mainfrom
nanavati:s0015-field-position

Conversation

@nanavati

@nanavati nanavati commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

What

The Prelude's split-port checks (checkPortNames, the excess-arg_names case of
methodArgBaseNames) reported S0015 primErrors at getEvalPosition of a (_ :: m)
proxy — a position only ever recovered from Ids embedded in the proxy's type (the
method type's tycons) via getIExprPosition's type fallback. So the error blamed an
incidental type use site, e.g. BadSplitInst_TooManyPortNames.bs:17:12.

Replace the type-side leak with a term-side source. GenWrap already passes each
WrapField call a StrArg name proxy; build it as a raw undefined stamped with the
interface field's decl position (mkStrArgProxyExpr) instead of a plain don't-care
(whose class-dispatched construction rebuilds the nullary StrArg constructor and loses
the position). The Prelude's WrapField instance takes getEvalPosition of that proxy
and threads a Position__ through the WrapMethod port-check methods
(methodArgBaseNames, inputPortNames, outputPortNames, saveMethodPortTypes) into
checkPortNames. The noinline path (fromWrapNoInline) uses the position of its name
string literal, which GenFuncWrap stamps with the function's def position.

The errors now point at the interface field being checked: 17:2 / 27:2 instead of
17:12 / 27:29. Two expected files regolded.

Why

Diagnostics improvement on its own — the field declaration is what the check is about.
It also removes the last S0015 dependence on positions carried inside type-embedded Ids:
the IType interning stack (#1048) strips those positions, and without this change the
errors degrade to "Unknown position".

Validation

bsc.verilog/splitports localcheck fully green (317 passes), plus bsc.bluetcl/commands
and bsc.typechecker/dontcare spot checks, all under the interning stack's checked build;
the full stack records fullparallel 20281/0/134.

Stack

Standalone on main. One of four independent fixes (#1051 (ATF canonical ids), #1052 (listcons SDataCon sort), #1053 (this), #1054 (CIclass sort members)) below the reworked #1048.

The Prelude's port-name checks (checkPortNames and the excess-arg_names
case of methodArgBaseNames) report primError at getEvalPosition of a
(_ :: m) type proxy, and that position is only ever recovered from Ids
embedded in the proxy's TYPE -- the method type's tycons.  So S0015
pointed at a type mentioned in the field's signature (e.g. Foo at
17:12), not at the field the user declared.

Report a term-side position instead.  GenWrap already passes each
WrapField call a StrArg name proxy; build that proxy as a raw undefined
stamped with the interface field's decl-side position
(mkStrArgProxyExpr) instead of a plain don't-care, whose
class-dispatched undefined construction rebuilds the nullary StrArg
constructor and loses the position.  The Prelude's WrapField instance
takes getEvalPosition of that proxy and threads a Position__ through
the WrapMethod port-check methods (methodArgBaseNames, inputPortNames,
outputPortNames, saveMethodPortTypes) into checkPortNames and the
excess-arg_names primError.  The noinline path (fromWrapNoInline) uses
the position of its name string literal, which GenFuncWrap stamps with
the function's def position.

The errors now point at the interface field being checked (its decl
Id): BadSplitInst_TooManyPortNames.bs 17:2 (was the type use at 17:12)
and TooManyArgNames.bs 27:2 (was 27:29).  Regold the two expected
files accordingly.

Validated: build green; bsc.verilog/splitports localcheck fully green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vjo7EmAfHvZTWPDJ923FVz
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