This code doesn't compile:
let f (x:byte) = printfn "%d" x
let b = int 'a'
f(byte <| b ||| 0x1)
(4,17): error FS0001: This expression was expected to have type
byte
but here has type
int
The F# operator table states the backward pipe operaotor (<|)
which has a form of (< op)
has a lower precedence than the bitwise or operator (|||)
:
So I thought (byte <| b ||| 0x1)
should be parsed as (byte <| (b ||| 0x1))
. But the compiler error message suggests it is parsed as ((byte <| b) ||| 0x1)
. What's happening here?
I just had a look at the FSharp specs and there <|
indeed has higher precedence than |||
(if I read the table right)
So most likely it's either an error in the MSDN docs or it was changed and not updated.
It's on page 35:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.