Fix culture-dependent number conversion and large JSON integer literals - #225
Open
Mike Krüger (mkrueger) wants to merge 2 commits into
Open
Mike Krüger (mkrueger) wants to merge 2 commits into
Mike Krüger (mkrueger) wants to merge 2 commits into
Conversation
Parse shell text, identifiers, and related parser conversions with invariant numeric styles so decimal text is not interpreted through the current culture. Add de-DE regression coverage for text decimal arithmetic. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Preserve out-of-range integer-form JSON literal values as raw JSON numbers while keeping plain integer expressions limited to Int32. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mike Krüger (mkrueger)
requested review from
a team
and
a balanced review from Copilot
September 29, 2026 13:01
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation is targeted, documented, and covered by relevant regression tests.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes culture-dependent numeric conversion and preserves large integer literals in JSON construction.
Changes:
- Uses invariant culture for numeric parsing.
- Supports exact large JSON integer literals, including negatives.
- Adds focused regression tests and programming documentation.
| File | Description |
|---|---|
docs/programming.md |
Documents invariant conversion and large JSON integers. |
ShellText.cs |
Parses numeric text invariantly. |
ShellObject.cs |
Uses invariant integer parsing. |
ShellJson.cs |
Parses numeric JSON strings invariantly. |
ShellIdentifier.cs |
Parses numeric identifiers invariantly. |
ExpressionParser.cs |
Supports large JSON integer literals. |
ExpressionTests.cs |
Tests large integer parsing and arithmetic. |
CultureInvariantConversionTests.cs |
Tests conversion under German culture. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Problem
Two bugs in how the scripting language handles numbers:
ShellTextandShellIdentifierparsed numbers with the current culture. On ade-DEsystem,.is a group separator, so$t = "1.5"; echo $($t * 2.0)printed30and$($t - 0.5)printed14.5, silently producing wrong values.Int32-only integer parsing, somkitem {"id":"1","ts":1727600000000}failed withInvalid number format. Millisecond timestamps and other 64-bit identifiers are common in Cosmos DB documents.Changes
Culture-invariant conversion (
Use invariant numeric shell conversions)ShellText,ShellIdentifier,ShellJson,ShellObject, and the remainingExpressionParserinteger paths usesNumberStyleswithCultureInfo.InvariantCulture, matching how the lexer already parses decimal literals.Large JSON integers (
Accept large JSON integer literals)Int32, including a leading unary-, become JSON number constants. The literal digits are preserved exactly, including values beyond 2^53. For example,{"n":9007199254740993}is stored without precision loss or a.0suffix.0..2147483647limit.double.docs/programming.mddocuments both behaviors.Tests
CultureInvariantConversionTestsrun underde-DE: text and identifier conversions, end-to-end expression evaluation, and rejection of"1,5".ExpressionTestscover large positive and negative integers in objects, arrays, and nested objects, values just aboveInt32.MaxValueand beyond 2^53, arithmetic on such properties, and the unchanged error for plain2147483648.