Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subtraction of two chars, new conversions, and fixes for dynamic operator invocations and QuotationToExpression #11681

Merged
merged 90 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from 86 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
f6c1859
Subtraction of two chars
Happypig375 Jun 15, 2021
60171b7
Update test.fsx
Happypig375 Jun 15, 2021
460c843
No extra lines
Happypig375 Jun 15, 2021
a81a42f
Update dynamic implementation
Happypig375 Jun 15, 2021
5d7318b
Update prim-types.fs
Happypig375 Jun 15, 2021
caab2f0
Update test.fsx
Happypig375 Jun 15, 2021
14857a4
lol
Happypig375 Jun 16, 2021
5f35033
char?
Happypig375 Jun 17, 2021
5e02343
Update test.fsx
Happypig375 Jun 17, 2021
f3147f2
Merge branch 'dotnet:main' into patch-7
Happypig375 Jun 17, 2021
1af5c2f
The missing piece
Happypig375 Jun 18, 2021
81658e7
Merge branch 'dotnet:main' into patch-7
Happypig375 Jun 18, 2021
6d31bad
Witness test refactor
Happypig375 Jun 18, 2021
7f09b96
Merge
Happypig375 Jun 18, 2021
ef8a96c
Fix types
Happypig375 Jun 19, 2021
e22d8eb
Decimals can't pow
Happypig375 Jun 19, 2021
1f0d8f9
You sneaky
Happypig375 Jun 19, 2021
bcf1bae
Fix precisions
Happypig375 Jun 19, 2021
6bc7625
Let me look at that exception
Happypig375 Jun 19, 2021
534e136
Fix it
Happypig375 Jun 20, 2021
28d16d2
More tests
Happypig375 Jun 20, 2021
9fcafbf
Fix twice
Happypig375 Jun 20, 2021
5dde7fc
Nullables are only for structs
Happypig375 Jun 20, 2021
a871549
Fix wrong operator
Happypig375 Jun 20, 2021
0a020af
3rd generic type parameter?
Happypig375 Jun 20, 2021
110c604
Conciseness
Happypig375 Jun 21, 2021
9457bf3
???
Happypig375 Jun 21, 2021
7fb2207
Back to method handles
Happypig375 Jun 21, 2021
c53999c
:/
Happypig375 Jun 21, 2021
134902d
Get tests passing?
Happypig375 Jun 21, 2021
0298c65
🤡
Happypig375 Jun 21, 2021
07b9d0d
Merge branch 'main' of https://github.com/dotnet/fsharp into patch-7
Happypig375 Jun 22, 2021
6947e61
Going ambitious
Happypig375 Jun 22, 2021
63fa1a7
How did tabs get in here?
Happypig375 Jun 22, 2021
9d819c0
Who doesn't like more testing?
Happypig375 Jun 22, 2021
51d397f
Undo that line, leave that to another time
Happypig375 Jun 22, 2021
bd11bdf
Ping...
Happypig375 Jun 23, 2021
06c19c8
More tests to feed the CI?
Happypig375 Jun 24, 2021
79fe88e
Here, have more tests
Happypig375 Jun 24, 2021
3bf7172
Howdy CI
Happypig375 Jun 25, 2021
7cfbd15
Persisting in times of despair
Happypig375 Jun 25, 2021
63b3eec
Merge branch 'main' into patch-7
vzarytovskii Jun 28, 2021
f20da15
Merge branch 'main' into patch-7
vzarytovskii Jun 29, 2021
97a8708
Is this it?
Happypig375 Jul 4, 2021
7bcba82
List is too long
Happypig375 Jul 4, 2021
e228dac
Introduce new conversions
Happypig375 Jul 5, 2021
d6efaf8
Checked
Happypig375 Jul 5, 2021
2acc8b5
Check correctly
Happypig375 Jul 5, 2021
365ca44
Equality enhanced
Happypig375 Jul 5, 2021
598babf
Quick fixes
Happypig375 Jul 5, 2021
b516100
Merge branch 'dotnet:main' into patch-7
Happypig375 Jul 5, 2021
3f77797
Solved it
Happypig375 Jul 5, 2021
61420dc
Remove unused branch
Happypig375 Jul 5, 2021
15c028f
Fix char->decimal
Happypig375 Jul 5, 2021
4213b3e
No <|
Happypig375 Jul 6, 2021
600941b
Fix conversion
Happypig375 Jul 6, 2021
d7961ce
Wait wait fix fix
Happypig375 Jul 6, 2021
3296101
Retype it
Happypig375 Jul 6, 2021
8ce408b
Respect truncation!
Happypig375 Jul 6, 2021
2c22e45
Truncate!
Happypig375 Jul 6, 2021
0107215
Simplifying refactor
Happypig375 Jul 7, 2021
824bf82
Consistent naming
Happypig375 Jul 7, 2021
6014407
Only invoke the method directly for boolean operators
Happypig375 Jul 7, 2021
bad346d
Fix comment
Happypig375 Jul 7, 2021
e5765a0
Related?
Happypig375 Jul 7, 2021
cd67954
Fix test
Happypig375 Jul 7, 2021
ceed28a
More tests
Happypig375 Jul 7, 2021
9df2c8e
Update test.fsx
Happypig375 Jul 8, 2021
1e34460
Oops wrong value
Happypig375 Jul 8, 2021
68bae88
More operations
Happypig375 Jul 14, 2021
2e29854
Uhhh... meow?
Happypig375 Jul 14, 2021
b37f075
Formatting
Happypig375 Jul 14, 2021
8907c02
Fix shifting
Happypig375 Jul 14, 2021
f8d487d
Merge branch 'dotnet:main' into patch-7
Happypig375 Aug 11, 2021
3c62992
Fix build error
Happypig375 Aug 13, 2021
24081cf
Fix bug
Happypig375 Aug 14, 2021
0aa574b
Fix warning
Happypig375 Aug 15, 2021
c53e913
Fix last bug
Happypig375 Aug 15, 2021
7098750
Tests yay
Happypig375 Aug 15, 2021
60bb94a
Address comments
Happypig375 Aug 16, 2021
ae77615
Try to fix tests
Happypig375 Aug 19, 2021
e350d81
Fix tests again
Happypig375 Aug 20, 2021
a274e20
Fix tests 3
Happypig375 Aug 20, 2021
700084d
Fix tests 4
Happypig375 Aug 20, 2021
1b456c8
Convert PhysicalEquality too
Happypig375 Aug 22, 2021
45213ab
Merge branch 'main' into patch-7
dsyme Oct 18, 2021
6a76304
Merge remote-tracking branch 'upstream/main' into patch-7
vzarytovskii Apr 20, 2022
b2e8d38
Merge remote-tracking branch 'upstream/main' into patch-7
vzarytovskii Jun 21, 2022
d8b4f45
Apply fantomas
vzarytovskii Jun 21, 2022
3344943
Merge branch 'main' into patch-7
vzarytovskii Jul 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions src/fsharp/ConstraintSolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ let isFpTy g ty =

/// decimal or decimal<_>
let isDecimalTy g ty =
typeEquivAux EraseMeasures g g.decimal_ty ty
typeEquivAux EraseMeasures g g.decimal_ty ty

let IsNonDecimalNumericOrIntegralEnumType g ty = IsIntegerOrIntegerEnumTy g ty || isFpTy g ty

Expand All @@ -439,7 +439,7 @@ let IsRelationalType g ty = IsNumericType g ty || isStringTy g ty || isCharTy g
let IsCharOrStringType g ty = isCharTy g ty || isStringTy g ty

/// Checks the argument type for a built-in solution to an op_Addition, op_Subtraction or op_Modulus constraint.
let IsAddSubModType nm g ty = IsNumericOrIntegralEnumType g ty || (nm = "op_Addition" && IsCharOrStringType g ty)
let IsAddSubModType nm g ty = IsNumericOrIntegralEnumType g ty || (nm = "op_Addition" && IsCharOrStringType g ty) || (nm = "op_Subtraction" && isCharTy g ty)

/// Checks the argument type for a built-in solution to a bitwise operator constraint
let IsBitwiseOpType g ty = IsIntegerOrIntegerEnumTy g ty || (isEnumTy g ty)
Expand Down Expand Up @@ -1564,25 +1564,30 @@ and SolveMemberConstraint (csenv: ConstraintSolverEnv) ignoreUnresolvedOverload
do! SolveTypeEqualsTypeKeepAbbrevs csenv ndeep m2 trace rty argty
return TTraitBuiltIn

// Conversions from non-decimal numbers / strings / chars to non-decimal numbers / chars are built-in
| _, _, false, "op_Explicit", [argty]
when (// The input type.
(IsNonDecimalNumericOrIntegralEnumType g argty || isStringTy g argty || isCharTy g argty) &&
// The output type
(IsNonDecimalNumericOrIntegralEnumType g rty || isCharTy g rty) &&
// Exclusion: IntPtr and UIntPtr do not support .Parse() from string
not (isStringTy g argty && isNativeIntegerTy g rty) &&
// Exclusion: No conversion from char to decimal
not (isCharTy g argty && isDecimalTy g rty)) ->
(IsNonDecimalNumericOrIntegralEnumType g rty || isCharTy g rty)) ->

return TTraitBuiltIn


// Conversions from (including decimal) numbers / strings / chars to decimals are built-in
| _, _, false, "op_Explicit", [argty]
when (// The input type.
(IsNumericOrIntegralEnumType g argty || isStringTy g argty) &&
(IsNumericOrIntegralEnumType g argty || isStringTy g argty || isCharTy g argty) &&
// The output type
(isDecimalTy g rty)) ->

return TTraitBuiltIn

// Conversions from decimal numbers to native integers are built-in
// The rest of decimal conversions are handled via op_Explicit lookup on System.Decimal (which also looks for op_Implicit)
| _, _, false, "op_Explicit", [argty]
when (// The input type.
(isDecimalTy g argty) &&
// The output type
(isNativeIntegerTy g rty)) ->
return TTraitBuiltIn

| [], _, false, "Pow", [argty1; argty2]
Expand Down
488 changes: 342 additions & 146 deletions src/fsharp/FSharp.Core/Linq.fs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/fsharp/FSharp.Core/Linq.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ module LeafExpressionConverter =
/// <example-tbd></example-tbd>
val SubstHelperRaw: Expr * Var[] * obj[] -> Expr

val internal (|SpecificCallToMethod|_|): System.RuntimeMethodHandle -> (Expr -> (Expr option * Type list * Expr list) option)
val internal (|SpecificCallToMethod|_|): System.RuntimeMethodHandle -> (Expr -> (Expr option * Reflection.MethodInfo * Expr list) option)
15 changes: 8 additions & 7 deletions src/fsharp/FSharp.Core/Query.fs
Original file line number Diff line number Diff line change
Expand Up @@ -314,26 +314,27 @@ module Query =
match prop.GetGetMethod true with
| null -> None
| v -> Some v
let (|GenericArgs|) (minfo: MethodInfo) = minfo.GetGenericArguments() |> Array.toList

// Match 'f x'
let (|SpecificCall1|_|) q =
let (|CallQ|_|) = (|SpecificCallToMethod|_|) q
function
| CallQ (Some builderObj, tyargs, [arg1]) -> Some(builderObj, tyargs, arg1)
| CallQ (Some builderObj, GenericArgs tyargs, [arg1]) -> Some(builderObj, tyargs, arg1)
| _ -> None

// Match 'f x y' or 'f (x, y)'
let (|SpecificCall2|_|) q =
let (|CallQ|_|) = (|SpecificCallToMethod|_|) q
function
| CallQ (Some builderObj, tyargs, [arg1; arg2]) -> Some(builderObj, tyargs, arg1, arg2)
| CallQ (Some builderObj, GenericArgs tyargs, [arg1; arg2]) -> Some(builderObj, tyargs, arg1, arg2)
| _ -> None

// Match 'f x y z' or 'f (x, y, z)'
let (|SpecificCall3|_|) q =
let (|CallQ|_|) = (|SpecificCallToMethod|_|) q
function
| CallQ (Some builderObj, tyargs, [arg1; arg2; arg3]) -> Some(builderObj, tyargs, arg1, arg2, arg3)
| CallQ (Some builderObj, GenericArgs tyargs, [arg1; arg2; arg3]) -> Some(builderObj, tyargs, arg1, arg2, arg3)
| _ -> None

/// (fun (x, y) -> z) is represented as 'fun p -> let x = p#0 let y = p#1' etc.
Expand Down Expand Up @@ -1286,7 +1287,7 @@ module Query =
// rewrite has had the custom operator translation mechanism applied. In this case, the
// body of the "for" will simply contain "yield".

| CallQueryBuilderFor (_, [_; qTy; immutResElemTy; _], [immutSource; Lambda(immutSelectorVar, immutSelector) ]) ->
| CallQueryBuilderFor (_, GenericArgs [_; qTy; immutResElemTy; _], [immutSource; Lambda(immutSelectorVar, immutSelector) ]) ->

let mutSource, sourceConv = TransInner CanEliminate.Yes check immutSource

Expand Down Expand Up @@ -1467,7 +1468,7 @@ module Query =
| _ -> GroupingConv (immutKeySelector.Type, immutElementSelector.Type, selectorConv)
TransInnerResult.Other(MakeGroupValBy(qTyIsIQueryable qTy, mutVar1.Type, mutKeySelector.Type, mutElementSelector.Type, mutSource, mutVar2, mutKeySelector, mutVar1, mutElementSelector)), conv

| CallJoin(_, [_; qTy; _; _; _],
| CallJoin(_, GenericArgs [_; qTy; _; _; _],
[ immutOuterSource
immutInnerSource
Lambda(immutOuterKeyVar, immutOuterKeySelector)
Expand All @@ -1491,7 +1492,7 @@ module Query =
TransInnerResult.Other joinExpr, elementSelectorConv

| CallGroupJoin
(_, [_; qTy; _; _; _],
(_, GenericArgs [_; qTy; _; _; _],
[ immutOuterSource
immutInnerSource
Lambda(immutOuterKeyVar, immutOuterKeySelector)
Expand All @@ -1517,7 +1518,7 @@ module Query =
TransInnerResult.Other joinExpr, elementSelectorConv

| CallLeftOuterJoin
(_, [ _; qTy; immutInnerSourceTy; _; _],
(_, GenericArgs [ _; qTy; immutInnerSourceTy; _; _],
[ immutOuterSource
immutInnerSource
Lambda(immutOuterKeyVar, immutOuterKeySelector)
Expand Down
3 changes: 1 addition & 2 deletions src/fsharp/FSharp.Core/fslib-extra-pervasives.fs
Original file line number Diff line number Diff line change
Expand Up @@ -378,5 +378,4 @@ namespace Microsoft.FSharp.Core.CompilerServices

type ITypeProvider2 =
abstract GetStaticParametersForMethod : methodWithoutArguments:MethodBase -> ParameterInfo[]
abstract ApplyStaticArgumentsForMethod : methodWithoutArguments:MethodBase * methodNameWithArguments:string * staticArguments:obj[] -> MethodBase

abstract ApplyStaticArgumentsForMethod : methodWithoutArguments:MethodBase * methodNameWithArguments:string * staticArguments:obj[] -> MethodBase
Loading