Skip to content

semantic: a position that requires a compile-time constant is left to Roslyn — a non-constant enum member value is CS0133, a default through H.x is CS1736, both behind SPY0908 #2432

Open

Description

@antonsynd

Class (contract): a position that requires a compile-time constant refuses a non-constant expression at semantic time, under its own diagnostic. It never reaches Roslyn behind SPY0908 (docs/design/spy0908-policy.md). The check exists for some spellings: SPY0401 fires on a plain default that reads a @static field. Other spellings and the enum member position pass the checker.

Found by the name-resolution differential (P77a, #2421) and its /verify-implementation round. Measured with sharpyc run @ 5f8a4c4.

position program observed expected
enum member value x: int = 5 / enum R0: / RED = x SPY0908 CS0133 a semantic refusal
enum member value RED = x() with def x() -> int SPY0908 CS0133 a semantic refusal
parameter default class H(B): def r(self, p0: int = H.x) with x a @static field inherited from B SPY0908 CS1736 SPY0401
parameter default def r(self, p0: int = H.x) with x a @static property SPY0908 CS1736 SPY0401
struct field initializer struct H: r: int = H.x with x a @static property SPY0908 CS1736 SPY0401
control def r(self, p0: int = H.x) with x a @static field on H itself SPY0401 SPY0401

The @static property arms sit next to #2417 (the read is untyped), but a typed read still needs this check to refuse it, so they belong here.

Lane / reach: ice · program. Allowlist rows in src/Sharpy.Compiler.Tests/Conformance/name-resolution-differential-allowlist.txt: every CS0133 and CS1736 cell cites this issue, and the row names the generated program.

Not probed: const initializers beyond the sweep's cells, attribute arguments, the dataclass field route outside the sweep's cells.

Activity

  1. added
    lane:ice
    reach:program
    class-tracker
    on Nov 5, 2026
  2. antonsynd commented on Nov 5, 2026

    @antonsynd
    OwnerAuthor

    Drain set @ fd925ddca (measured): 27 rows cite this issue: CS0133 / CS1736 in a constant position. They cited #2423 only through a default arm in the harness's route, which is gone.

    Rows
    read/ClassComputedConst/ParameterDefault/base/H.x Ice
    read/ModuleClass/EnumMemberValue/Earlier/Bare/outer=None Ice
    read/ModuleClass/EnumMemberValue/Later/Bare/outer=None Ice
    read/ModuleComputedConst/EnumMemberValue/Earlier/Bare/outer=None Ice
    read/ModuleComputedConst/EnumMemberValue/Later/Bare/outer=None Ice
    read/ModuleDef/EnumMemberValue/Earlier/Bare/outer=None Ice
    read/ModuleDef/EnumMemberValue/Later/Bare/outer=None Ice
    read/ModuleProperty/EnumMemberValue/Earlier/Bare/outer=None Ice
    read/ModuleProperty/EnumMemberValue/Later/Bare/outer=None Ice
    read/ModuleStruct/EnumMemberValue/Earlier/Bare/outer=None Ice
    read/ModuleStruct/EnumMemberValue/Later/Bare/outer=None Ice
    read/ModuleVar/EnumMemberValue/Earlier/Bare/outer=None Ice
    read/StaticField/ParameterDefault/base/H.x Ice
    read/StaticProperty/DataclassFieldInitializer/Earlier/Qualified/outer=ModuleVar Ice
    read/StaticProperty/DataclassFieldInitializer/Earlier/Qualified/outer=None Ice
    read/StaticProperty/DataclassFieldInitializer/Later/Qualified/outer=ModuleVar Ice
    read/StaticProperty/DataclassFieldInitializer/Later/Qualified/outer=None Ice
    read/StaticProperty/ParameterDefault/Earlier/Qualified/outer=ModuleVar Ice
    read/StaticProperty/ParameterDefault/Earlier/Qualified/outer=None Ice
    read/StaticProperty/ParameterDefault/Later/Qualified/outer=ModuleVar Ice
    read/StaticProperty/ParameterDefault/Later/Qualified/outer=None Ice
    read/StaticProperty/ParameterDefault/base/B.x Ice
    read/StaticProperty/ParameterDefault/base/H.x Ice
    read/StaticProperty/StructFieldInitializer/Earlier/Qualified/outer=ModuleVar Ice
    read/StaticProperty/StructFieldInitializer/Earlier/Qualified/outer=None Ice
    read/StaticProperty/StructFieldInitializer/Later/Qualified/outer=ModuleVar Ice
    read/StaticProperty/StructFieldInitializer/Later/Qualified/outer=None Ice
    

    These shas are on local dev, not pushed yet.

  3. antonsynd commented on Nov 5, 2026

    @antonsynd
    OwnerAuthor

    Batching 2026-11-05 @ ee9a007 — charter .claude/plans/remediation-round-2026-09-20-batching.md §3.20l, P78 — N1/N2/N4/N7: scope decides meaning (order 6c⁶⁵: directly after P77, before P79). Ruling R-KV (owner, 2026-11-05, D8): (a) P78 — the constant-position validator's membership walk under N4 ("constants are not special": foldability decides legality, never what a name means); the plan author may split it off as P78b if the gate is too wide.

    Contract: every position that requires a compile-time constant (enum member value, parameter default, struct field default, dataclass field default) reaches the same verdict for the same expression kind — SPY0401 for a non-constant, never CS0133/CS1736 behind SPY0908. Lane / reach: ice · program. Cells (27 allowlist rows citing this issue @ ee9a007): enum member value RED = x / RED = x() → CS0133; a parameter default / struct field / dataclass field through an INHERITED static or a @static property → CS1736; the own-static control is SPY0401. One class: position × expression kind {own static, inherited static, static property, call, alias}. Joins P78 beside #2398's interface/union parameter-default cell (SPY0200 + SPY0401 → one diagnostic). Rejected: (b) P30 — the validator reads the member-shape table P30 builds (static-ness, inherited, property), but the enum position stays an outlier there; P30's table is a dependency P78 reads when it lands. Two-way (placement). Class tracker: this issue.

  4. antonsynd commented on Nov 6, 2026

    @antonsynd
    OwnerAuthor

    Drain set after P77b (name-resolution differential, branch remote/p77b-implement-plan @ 0c0bdcf)

    29 rows of src/Sharpy.Compiler.Tests/Conformance/name-resolution-differential-allowlist.txt cite this issue (27 at the plan base 2279c0d), all read Ice. When the cure lands, every one of these rows must drain: a stale row fails the sweep.

    To list them: grep -n '# #2432' src/Sharpy.Compiler.Tests/Conformance/name-resolution-differential-allowlist.txt


    Generated by Claude Code

  5. 5 remaining items

  6. added a commit that references this issue on Nov 18, 2026
  7. antonsynd commented on Nov 18, 2026

    @antonsynd
    OwnerAuthor

    PR #2742 (P77) drains two rows of this issue from name-resolution-differential-allowlist.txt (commit 410a688):

    • read/ClassComputedConst/ParameterDefault/base/H.x Ice
    • read/StaticField/ParameterDefault/base/H.x Ice

    Both now Match. The cause is a P77 fix: TryResolveTypeMemberAccess binds a static or const reached through a subclass to its declaring symbol (866a9a2), so the default through the base resolves as C.x does. The issue's other rows stay.


    Generated by Claude Code

  8. antonsynd commented on Nov 20, 2026

    @antonsynd
    OwnerAuthor

    Two cells of this class found by plan-777361's (P78) revision after pass 2, outside that plan's contract. Both measured with sharpyc run, Debug, product code == e24aaf9f0 (origin/dev).

    Cell Program Observed Expected Lane Reach
    enum member value × a constant of a wider integer type from system import Int64 / enum Q: / RED = Int64.max_value / def main(): / print(1) SPY0908 CS0266 ("Cannot implicitly convert type 'long' to 'int'") a checker refusal at the member value ice probe
    attribute argument × unused-import warning from system import Math / import system.component_model / class H: / @[system.component_model.default_value(Math.PI)] / property p: float = 1.0 / def main(): / print(H().p) runs 1.0, with SPY0452 "Imported name 'Math' is never used" and the same for system.component_model no warning: both imports are used by the attribute message probe

    The second goes away once the checker visits bracket-attribute arguments, which P78's plan now carries (its D8, pass-2 finding 3).


    Generated by Claude Code

  9. antonsynd commented on Nov 20, 2026

    @antonsynd
    OwnerAuthor

    Cell, in P78's contract (plan-777361, held by its acceptance A14). Measured with sharpyc project / run on product code == dev @ e24aaf9f0; the multi-file route was not measured by verify pass 3.

    Imported module consts declares const Q with a computed (non-literal) initializer; the importer reads it at a parameter default.

    Importer spelling Observed Expected
    import consts / def f(p: int = consts.Q) SPY0908 behind CS1736 SPY0401
    import consts as c0 / def f(p: int = c0.Q) SPY0908 behind CS1736 SPY0401
    the three from-import forms, def f(p: int = Q) SPY0401 SPY0401
    an imported literal const and an imported class's const at a default, all five forms run, print 5 9 run

    These figures are the revising agent's measurement; verify pass 4 has not graded them yet.


    Generated by Claude Code

  10. antonsynd commented on Nov 20, 2026

    @antonsynd
    OwnerAuthor

    Cell (found by the independent review of PR #2767's test code; not generated, by the owner's decision of #2423 comment 7052893050 item 26). The arrow-lambda spelling takes a function-typed parameter annotation with a default, and a non-constant there reaches Roslyn.

    Program Observed Expected
    import math / f = (p: (float) -> float = math.sqrt) -> p ✔ SPY0908 behind CS1736 SPY0401
    f = (p: () -> int = five) -> p SPY0401 SPY0401 (control)
    f = (p: system.DayOfWeek = system.DayOfWeek.Monday) -> p runs runs (control)

    P78's generator has a lambda-keyword host for a lambda's default and none for the arrow spelling, though the same validator call judges both. ✔ = reproduced with sharpyc run on product code == dev @ e24aaf9f0. Lane: ice · reach: program.


    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    class-trackerlane:icereach:program

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions