Skip to content

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

Closed

Description

@marklam

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

Activity

  1. TIHan commented on Jul 3, 2018

    @TIHan
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions