-
Notifications
You must be signed in to change notification settings - Fork 803
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
Fix 457 - add ones complement operator with backwards compat #458
Conversation
Yeah seems like Will this play nicely with quotations when used cross-version? e.g. https://code.google.com/p/unquote/issues/detail?id=49&can=1&q=op_LogicalNot |
It should all work across version. So <@ ~~~1 @> compiled with F# 3.1 and evaluated with F# 4.0 (or with an F# 3.x component with a binding redirect to FSharp.Core 4.4.0.0) should work correctly. That testing would be good to add (basically cross-version execution for tests/fsharp/core/queriesLeafExpressionConvert/test.fsx I believe) |
@@ -531,6 +532,7 @@ module LeafExpressionConverter = | |||
| LessQ (_, _,[x1;x2]) -> transBinOp env false x1 x2 false Expression.LessThan | |||
| LessEqQ (_, _,[x1;x2]) -> transBinOp env false x1 x2 false Expression.LessThanOrEqual | |||
| NotQ (_, _, [x1]) -> Expression.Not(ConvExprToLinqInContext env x1) |> asExpr | |||
| LogicalNotQ (_, _, [x1]) -> Expression.Not(ConvExprToLinqInContext env x1) |> asExpr |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking!
Blah, this indeed has some nasty cross-version problems. Scenario 1printfn "%A" <| (~~~ 2)
Scenario 2module Test
let q = <@ ~~~ 1 @>
Scenario 3module Test
let (!!!) (b : bool) =
printfn "in custom bool !!! op"
b
Scenario 4module Test
let (~~~) (b : bool) =
printfn "in custom bool ~~~ op"
b
|
Urgh. Good work. Tricky problems. I'll take a look tomorrow. It's possible most of the "4.0 targeting 3.1" problems go away if we vary the name mapping used based on a 4.3.x.0 v. 4.4.0.0 library target. |
@@ -405,13 +405,14 @@ type public TcGlobals = | |||
bitwise_or_vref : ValRef; | |||
bitwise_and_vref : ValRef; | |||
bitwise_xor_vref : ValRef; | |||
bitwise_unary_not_vref : ValRef; | |||
bitwise_unary_logical_not_vref : ValRef; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the naming of this correct? I always thought bitwise and logical were mutually exclusive.
This is VNext at this stage (hopefully first OOB, if we can find a way to make it fully backwards compat, otherwise next major language revision I suppose) |
This has been idle for a couple months and not yet clear how to fix this without a surface area change and still maintain cross-version compat. Thus closing out for now. |
@latkin I'm not sure "idle for a couple of months" is justification when the repo has effectively been closed for business for bug fixing for at least a couple of months :) Lets just prompt the owners to reopen the PRs against the appropriate branch? |
@dsyme I'm only closing idle PRs which have unresolved feedback and/or known issues, not those which are thought to be fully ready but "waiting in the queue." |
My fear for this particular one is that if it's closed - apart from bug #457 - then I'll just keep punting it. "Out of sight out of mind, I tried once and it didn't stick so I gave up" etc. We need to have a plan in place to fix this in the language design. I suppose tracking it on fslang.uservoice.com would make sense since it's effectively baked in as part of the 4.0 design at the moment. |
Given the failure of the above approach I suppose a way forward would be
Does that sound reasonable? If the approach is sound then steps 1-2 require updating FSharp.Core of course. |
I've added an entry on fslang.uservoice.com to track this: http://fslang.uservoice.com/forums/245727-f-language/suggestions/9168976-add-complement-and-logicalnot-operators-to-res, documenting the above plan |
That sounds reasonable to me |
This is a tentative fix for #457
Some testing still needs to be added:
The F# Language Spec will need to be updated to say !!! is for op_LogicalNot and ~~~ is for op_OnesComplement.
In theory this is a breaking change in some situations - in particular "let (~~~) x = x" now compiles as a function called "op_OnesComplement" instead of "op_LogicalNot". However FSharp.Core remains fully backwards binary compatible because both functions are now present. I think this is ok given the situation.