Skip to content

Fix FS0452 for empty string pattern matching in quotations#19532

Merged
abonie merged 4 commits intomainfrom
copilot/fix-quotation-string-matching
Apr 1, 2026
Merged

Fix FS0452 for empty string pattern matching in quotations#19532
abonie merged 4 commits intomainfrom
copilot/fix-quotation-string-matching

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

The empty string pattern optimization (.Length = 0 instead of .Equals("")) introduced mkNonNullTest which emits [AI_ldnull; AI_cgt_un] IL. The quotation translator had no handler for this pattern, falling through to the inline-IL error.

// This started failing with FS0452
let q = <@ fun (x: string) -> match x with "" -> "empty" | _ -> "other" @>

Changes

  • QuotationTranslator.fs: Handle [AI_ldnull; AI_cgt_un] by converting to arg <> null via mkCallNotEqualsOperator, mirroring how [AI_ceq] is already handled via mkCallEqualsOperator
  • Regressions.fs: Add regression tests for empty string, mixed string, and non-empty string pattern matching in quotations, plus a runtime shape verification test

Copilot AI and others added 2 commits March 31, 2026 14:06
Copilot AI changed the title [WIP] Fix quotation string matching issue in project Fix FS0452 for empty string pattern matching in quotations Mar 31, 2026
Copilot AI requested a review from T-Gro March 31, 2026 14:13
@T-Gro T-Gro marked this pull request as ready for review April 1, 2026 07:39
@T-Gro T-Gro requested a review from a team as a code owner April 1, 2026 07:39
@T-Gro T-Gro requested a review from abonie April 1, 2026 07:39
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

❗ Release notes required

@copilot,

Caution

No release notes found for the changed paths (see table below).

Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format.

The following format is recommended for this repository:

* <Informative description>. ([PR #XXXXX](https://github.com/dotnet/fsharp/pull/XXXXX))

See examples in the files, listed in the table below or in th full documentation at https://fsharp.github.io/fsharp-compiler-docs/release-notes/About.html.

If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request.

You can open this PR in browser to add release notes: open in github.dev

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/11.0.100.md No release notes found or release notes format is not correct

@github-project-automation github-project-automation bot moved this from New to In Progress in F# Compiler and Tooling Apr 1, 2026
Copilot finished work on behalf of T-Gro April 1, 2026 08:34
Copilot AI requested a review from T-Gro April 1, 2026 08:34
@abonie abonie merged commit 6a5df48 into main Apr 1, 2026
46 checks passed
@abonie
Copy link
Copy Markdown
Member

abonie commented Apr 2, 2026

/backport to backport/pr-19532

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

Started backporting to backport/pr-19532 (link to workflow run)

@abonie
Copy link
Copy Markdown
Member

abonie commented Apr 3, 2026

/backport to pr-19532-rel-insiders

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

Started backporting to pr-19532-rel-insiders (link to workflow run)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

@abonie backporting to pr-19532-rel-insiders failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch --exclude=docs/release-notes/* --exclude=eng/common/* --whitespace=fix changes.patch

Creating an empty commit: Initial plan
Applying: Fix FS0452: Handle non-null test IL pattern in quotation translator for empty string matching
Using index info to reconstruct a base tree...
A	tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/ExpressionQuotations/Regressions.fs
Falling back to patching base and 3-way merge...
CONFLICT (modify/delete): tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/ExpressionQuotations/Regressions.fs deleted in HEAD and modified in Fix FS0452: Handle non-null test IL pattern in quotation translator for empty string matching.  Version Fix FS0452: Handle non-null test IL pattern in quotation translator for empty string matching of tests/FSharp.Compiler.ComponentTests/Conformance/Expressions/ExpressionQuotations/Regressions.fs left in tree.
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0002 Fix FS0452: Handle non-null test IL pattern in quotation translator for empty string matching
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

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

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Quotation string matching fails?

3 participants