refactor(js/ts/python): use struct partial active patterns and postfix array syntax#4569
Merged
dbrattli merged 5 commits intoApr 26, 2026
Conversation
…ectly converted (#4560) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Dag Brattli <dag@brattli.net> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fix code scanning alerts IONIDE-009 (alerts #1056-#1058, #1069-#1070, #1083) and IONIDE-002 (alerts #1065, #1072, #1181). - Add [<return: Struct>] to partial active patterns in BabelPrinter.fs and Python transforms to avoid heap allocation for option types - Replace [] postfix array syntax with the idiomatic 'array' postfix syntax in BabelPrinter.fs, Fable2Python.Util.fs, and Python.AST.fs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Fixes code scanning alerts from Ionide.Analyzers (IONIDE-009 and IONIDE-002):
IONIDE-009 (alerts Docs: Provide guidance for fable nuget publish #1056, reraise doesn't work correctly in JS #1057, Support String.Join with objects #1058, Prevent dotnet template engine to parse Paket.Restore.targets #1069, Fable Simple Template dotnet-fable require manual installation of several missing package dependencies when the user .nuget and .dotnet directories does not exists or empty #1070, Implement isDaylightSavingTime #1083): Add
[<return: Struct>]to partial active patterns inBabelPrinter.fsand Python transform files. This avoids heap allocation for theoptionreturn type, since the patterns return simple values (unit, string, or tuples) that benefit fromValueOptionstruct representation.IONIDE-002 (alerts Repl target fix #1065, Curried Applicative issue #1072, Is it possible to emit an error when RegexOptions.Singleline is used? #1181): Replace C#-style
[]postfix syntax with idiomatic F#arraypostfix syntax inBabelPrinter.fs,Fable2Python.Util.fs, andPython.AST.fs.Files Changed
src/Fable.Transforms/BabelPrinter.fs[<return: Struct>]onUndefinedOrVoid,NullOrUndefinedOrVoid,StringConstant;TypeParameter arraysrc/Fable.Transforms/Python/Fable2Python.Util.fs[<return: Struct>]onFunction,IEnumerableOfKeyValuePair;Fable.Ident arraysrc/Fable.Transforms/Python/Fable2Python.Transforms.fs[<return: Struct>]onUsePatternsrc/Fable.Transforms/Python/Python.AST.fsbyte arrayNotes
These are purely cosmetic/performance changes with no semantic impact. Struct partial active patterns work identically in
matchexpressions; callers do not need to change.