Skip to content

fix: add type specifiers to interpolated strings#4646

Merged
dbrattli merged 1 commit into
mainfrom
fix/interpolated-string-specifiers
Jun 12, 2026
Merged

fix: add type specifiers to interpolated strings#4646
dbrattli merged 1 commit into
mainfrom
fix/interpolated-string-specifiers

Conversation

@dbrattli

Copy link
Copy Markdown
Collaborator

Summary

Resolves all 127 GRA-INTERPOLATED-001 code-scanning alerts — "missing type specifiers in interpolated strings" — across 17 source files in Fable.Compiler and Fable.Transforms.

Each flagged interpolation hole gets the correct %-specifier so the type is checked at compile time. Output is unchanged; this only adds compile-time type safety:

  • %s for strings (names, full names, formatted types, paths, error/warning messages) — the majority
  • %d for ints (generated identifiers like arg{i}, FSharpChoice${n}, union tags, counters, arities)
  • %O for objects whose default formatting already called ToString() (DateTime timestamps, Fable.Type, obj values, string option)

One site (FSharp2Fable.Util.fs) had a multi-line if/else inside the hole that went offside once the prefix widened, so it was hoisted into a small staticSuffix binding.

Verification

dotnet build src/Fable.Cli/Fable.Cli.fsproj -c Release succeeds with 0 warnings, 0 errors. The build itself is the safety net: a wrong specifier (%s on a non-string, %d on a non-int) is a hard compile error, so a clean build confirms every choice is type-correct. The identifier-generating strings (which feed into generated code, not just messages) produce byte-identical output, so there is no behavior change.

🤖 Generated with Claude Code

Resolve all 127 GRA-INTERPOLATED-001 code-scanning alerts ("missing type
specifiers in interpolated strings") by adding the correct %-specifier to
every flagged interpolation hole. Output is unchanged; the specifiers add
compile-time type checking:

- %s for strings (names, full names, formatted types, paths, messages)
- %d for ints (generated identifiers, union tags, counters, arities)
- %O for objects whose default formatting already called ToString()
  (DateTime timestamps, Fable.Type, obj values, string option)

The clean build is the verification: a wrong specifier is a compile error.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Python Type Checking Results (Pyright)

Metric Value
Total errors 34
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_hash_set.py 18 Excluded
temp/tests/Python/test_applicative.py 12 Excluded
temp/tests/Python/test_nested_and_recursive_pattern.py 2 Excluded
temp/tests/Python/fable_modules/thoth_json_python/encode.py 2 Excluded

@dbrattli dbrattli requested review from MangelMaxime and ncave June 10, 2026 22:13
@dbrattli

Copy link
Copy Markdown
Collaborator Author

This should be safe since a wrong specifier should trigger a compile error. But touches many files, so please have a look and approve the PR if it looks OK with you @MangelMaxime @ncave

@dbrattli dbrattli merged commit 512ae4d into main Jun 12, 2026
34 checks passed
@dbrattli dbrattli deleted the fix/interpolated-string-specifiers branch June 12, 2026 12:06
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.

3 participants