Skip to content

[Repo Assist] Fix code scanning alerts: unsafe option unwrapping and struct active patterns#4473

Merged
dbrattli merged 5 commits intomainfrom
repo-assist/codescan-ionide-warnings-20260402-00f2663-aae0bff37b25caec
Apr 3, 2026
Merged

[Repo Assist] Fix code scanning alerts: unsafe option unwrapping and struct active patterns#4473
dbrattli merged 5 commits intomainfrom
repo-assist/codescan-ionide-warnings-20260402-00f2663-aae0bff37b25caec

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 2, 2026

Summary

Fixes multiple open code scanning alerts from the Ionide analyzer:

IONIDE-006 (warning): Unsafe option unwrapping

  • src/Fable.Transforms/Python/Replacements.fs — alert #1203: thisArg.Value replaced with thisArg |> Option.map (fun this -> ...) to safely handle the None case
  • src/Fable.Transforms/Rust/Fable2Rust.fs — alerts #1126, #1127: name.Value replaced with explicit match on (isTailRec, name) / (isRecursive && not isTailRec, name). In practice these values can never be None when the guard is true (since isTailRecursive returns false, false when name is None), but the explicit pattern match makes the invariant visible to both humans and the analyzer.

IONIDE-009 (note): Missing [(return: Struct)] on partial active patterns

Adds [(return: Struct)] to partial active patterns in:

  • src/Fable.Transforms/Dart/Fable2Dart.fs(|Function|_|) and (|Lets|_|) (alerts #1105, #1106)
  • src/Fable.Transforms/Dart/Replacements.fs(|DartInt|_|) and (|DartDouble|_|) (alert #1177)
  • src/Fable.Transforms/Rust/Fable2Rust.fs(|HasEmitAttribute|_|), (|HasReferenceTypeAttribute|_|), (|IsNonErasedInterface|_|), (|Function|_|), (|Lets|_|), (|IDisposable|_|), (|IFormattable|_|), (|IComparable|_|), (|IEquatable|_|), (|IEnumerable|_|) (alerts #1115#1124)

The [(return: Struct)] attribute changes the internal return type from Option(T) to ValueOption(T), reducing heap allocations for these frequently-called patterns. Callers that use them in pattern matching require no changes — the F# compiler handles the conversion transparently.

Test plan

  • CI passes for all targets (JavaScript, TypeScript, Python, Rust, Dart)
  • These are purely code-quality and performance fixes; no observable behaviour changes

🤖 Generated with Repo Assist

Note

🔒 Integrity filtering filtered 11 items

Integrity filtering activated and filtered the following items during workflow execution.
This happens when a tool call accesses a resource that does not meet the required integrity or secrecy level of the workflow.

  • #4472 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4220 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4166 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4143 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4104 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4044 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #4038 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #3290 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • #2279 (list_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • resource:search_pull_requests (search_pull_requests: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
  • issue:Take zero-arity into account when uncurrying #2897 (issue_read: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

…patterns

- Replace unsafe `.Value` on option types with safe pattern matching
  in Python/Replacements.fs (#1203) and Rust/Fable2Rust.fs (#1126, #1127)
- Add [<return: Struct>] to partial active patterns in Dart/Fable2Dart.fs
  (#1105, #1106), Dart/Replacements.fs (#1177), and Rust/Fable2Rust.fs
  (#1115, #1116, #1117, #1118, #1119, #1120, #1121, #1122, #1123, #1124)
  to reduce heap allocations

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added automation Automated changes optimization repo-assist Created by Repo Assist labels Apr 2, 2026
@dbrattli dbrattli marked this pull request as ready for review April 2, 2026 04:52
dbrattli and others added 2 commits April 2, 2026 07:06
The repo-assist PR added [<return: Struct>] to partial active patterns
but didn't update the bodies from Some/None to ValueSome/ValueNone.
Also expand or-patterns for struct active patterns (DartInt | DartDouble)
since F# doesn't allow struct active patterns in or-patterns, and pipe
Seq.tryPick through Option.toValueOption for Rust active patterns.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 2, 2026

Python Type Checking Results (Pyright)

Metric Value
Total errors 18
Files with errors 4
Excluded files 4
New errors ✅ No
Excluded files with errors (4 files)

These files have known type errors and are excluded from CI. Remove from pyrightconfig.ci.json as errors are fixed.

File Errors Status
temp/tests/Python/test_applicative.py 12 Excluded
temp/tests/Python/test_hash_set.py 3 Excluded
temp/tests/Python/test_nested_and_recursive_pattern.py 2 Excluded
temp/tests/Python/fable_modules/thoth_json_python/encode.py 1 Excluded

@dbrattli dbrattli requested a review from ncave April 2, 2026 08:54
@dbrattli dbrattli merged commit ea87e3b into main Apr 3, 2026
25 checks passed
@dbrattli dbrattli deleted the repo-assist/codescan-ionide-warnings-20260402-00f2663-aae0bff37b25caec branch April 3, 2026 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation Automated changes optimization repo-assist Created by Repo Assist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants