Conversation
…pt type annotation The nameAndTypeRegex used RegexOptions.RightToLeft, which caused incorrect splits when a column name contained parentheses. For example, the schema "Na( )me (int)" was parsed as name="Na", type=" )me (int)" instead of the correct name="Na( )me", type="int". Without RightToLeft, the greedy .+ quantifier on the name group naturally backtracks and matches the *last* "(type)" group at the end of the string, which is the correct behaviour. Fixes #946. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4 tasks
dsyme
approved these changes
Feb 22, 2026
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.
🤖 Repo Assist here — I'm an automated AI assistant for this repository.
Closes #946Problem
When a CSV
Schemaparameter includes a column whose name contains parentheses, the type annotation is corrupted. For example:This was reported in #946 in 2016 and confirmed as reproducible.
Root Cause
CsvInference.fsline 39 definednameAndTypeRegexwithRegexOptions.RightToLeft:In RightToLeft mode, the regex engine starts from the right end of the string and scans leftward. When the column name contains a
(character, the greedy.+for the type group sweeps past the intended(type)boundary and instead anchors the\(separator on the first(in the string — giving a completely wrong parse.Fix
Remove
RegexOptions.RightToLeftfromnameAndTypeRegex. Without it, the standard left-to-right greedy engine correctly backtracks the name.+until the trailing(type)pattern matches — always landing on the last(...)at the end of the string, which is the intended semantics.Note:
overrideByNameRegexretains RightToLeft intentionally, as that pattern must find the last->or=separator when the column name may contain those characters.Test
Added a regression test
Column name with parentheses is parsed correctly in schematoInferenceTests.fs.Test Status
dotnet build src/FSharp.Data.Csv.Core/)FSharp.Data.DesignTime.Testspass — 49/49 inference tests pass (includes new regression test)FSharp.Data.Testscould not be built: the WorldBank type provider requires network access toapi.worldbank.org, which is blocked by the build environment's network proxy. This is unrelated to this change.Warning
The following domain was blocked by the firewall during workflow execution:
api.worldbank.org