refactor(all): mark enum-like DUs [<Struct>] to satisfy StructDiscriminatedUnionAnalyzer#4665
Merged
Merged
Conversation
…inatedUnionAnalyzer Resolve the editable IONIDE-012 (StructDiscriminatedUnionAnalyzer) code scanning alerts by marking the flagged discriminated unions as structs. Most are enum-like/single-case DUs needing only the [<Struct>] attribute. A few multicase DUs with unnamed fields also required unique field names to satisfy the struct-union rule (FS3585); positional pattern matching is preserved so call sites are unaffected: - Php.fs: PhpConst, PhpArrayIndex, Capture, PhpCase - Fable2Php.fs: ReturnStrategy - FSharp2Fable.Util.fs: CompiledValue - Globbing.fs (+ .fsi): SearchOption - Util.fs: AttParam Alerts in src/Fable.AST/ are intentionally left untouched: adding [<Struct>] there would change a public type from reference to value type, a breaking change disallowed for that project. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Python Type Checking Results (Pyright)
Excluded files with errors (4 files)These files have known type errors and are excluded from CI. Remove from
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves the editable IONIDE-012 (
StructDiscriminatedUnionAnalyzer) code scanning alerts by marking the flagged discriminated unions[<Struct>]— the same pattern already used forFieldNamingKind,ClassStyle, andAtom.62 alerts across 20 files are addressed:
[<Struct>]attribute (bulk inRust.AST.Types.fs×26,Python.AST.fs×6,Global/Babel.fs×6,Dart/Dart.fs×4, …).FS3585). Positional pattern matching is preserved, so call sites are unaffected:Php.fs:PhpConst,PhpArrayIndex,Capture,PhpCaseFable2Php.fs:ReturnStrategyFSharp2Fable.Util.fs:CompiledValueGlobbing.fs(+ its.fsisignature):SearchOptionUtil.fs:AttParamLeft untouched
The 8 IONIDE-012 alerts in
src/Fable.AST/(Common.fs,Fable.fs,Plugins.fs) are intentionally not changed. Adding[<Struct>]there would flip a public type from a reference type to a value type — a breaking change disallowed for that project.Verification
Fable.Cli(→Fable.Transforms+Fable.Compiler) andFable.Standalonebuild clean.null/Unchecked.defaultofusages on the changed compiler-logic types (the only behavioral axis[<Struct>]affects).🤖 Generated with Claude Code