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

Can't pipe byref into function, but can apply it directly #5286

Closed
marklam opened this issue Jul 3, 2018 · 1 comment
Closed

Can't pipe byref into function, but can apply it directly #5286

marklam opened this issue Jul 3, 2018 · 1 comment

Comments

@marklam
Copy link

marklam commented Jul 3, 2018

Passing a byref argument using the forward-pipe doesn't work, get "error FS0412: A type instantiation involves a byref type. This is not permitted by the rules of Common IL."

Repro steps

open System.Buffers.Binary

module X = 
    let thisIsOK s  = BinaryPrimitives.ReadInt32BigEndian s
    let thisIsNot s = s |> BinaryPrimitives.ReadInt32BigEndian

Expected behavior

The forward-pipe should work the same as directly supplying the parameter to the function

Actual behavior

The compiler complains

Known workarounds

Not using the forward-pipe

Related information

.net standard 2.0
VisualStudio.15.Preview/15.8.0-pre.3.0+27825.0
Visual F# Tools 10.2 for F# 4.5 15.8.0.0. Commit Hash: ac667ab

@TIHan
Copy link
Contributor

TIHan commented Jul 3, 2018

This is intended. Because |> is a generic function, the rules state you can't have a byref<_> as a type arg, ex: callSomething<byref<int>>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants