Skip to content

Commit 20f2090

Browse files
committed
Fix NumberParser for integer < int.MinValue
1 parent 479ab6d commit 20f2090

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/System.Linq.Dynamic.Core/Parser/NumberParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public Expression ParseIntegerLiteral(int tokenPosition, string text)
149149
throw new ParseException(Res.MinusCannotBeAppliedToUnsignedInteger, tokenPosition);
150150
}
151151

152-
if (value <= int.MaxValue)
152+
if (value >= int.MinValue && value <= int.MaxValue)
153153
{
154154
return _constantExpressionHelper.CreateLiteral((int)value, textOriginal);
155155
}

test/System.Linq.Dynamic.Core.Tests/Parser/NumberParserTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
using FluentAssertions;
21
using System.Collections.Generic;
32
using System.Globalization;
43
using System.Linq.Dynamic.Core.Parser;
54
using System.Linq.Expressions;
5+
using FluentAssertions;
66
using Xunit;
77

88
namespace System.Linq.Dynamic.Core.Tests.Parser;
@@ -129,6 +129,8 @@ public void NumberParser_ParseNumber_Double(string? culture, string text, double
129129
[Theory]
130130
[InlineData("42", 42)]
131131
[InlineData("-42", -42)]
132+
[InlineData("3000000000", 3000000000)]
133+
[InlineData("-3000000000", -3000000000)]
132134
[InlineData("77u", 77)]
133135
[InlineData("77l", 77)]
134136
[InlineData("77ul", 77)]

0 commit comments

Comments
 (0)