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

Base calls with byref arguments are not analyzed correctly #108

Closed
KevinRansom opened this issue Jan 26, 2015 · 1 comment
Closed

Base calls with byref arguments are not analyzed correctly #108

KevinRansom opened this issue Jan 26, 2015 · 1 comment
Labels

Comments

@KevinRansom
Copy link
Member

Originally opened at CodePlex bykvb
Based on the problem reported here: http://stackoverflow.com/questions/24324547/f-method-with-byref-parameter-override.

This fails to compile

type Incrementor(z) =
    abstract member Increment : int byref * int byref -> unit
    default this.Increment(i : int byref,j : int byref) =
       i <- i + z

type Decrementor(z) =
    inherit Incrementor(z)
    override this.Increment(i, j) =
        base.Increment(&i, &j)

        i <- i - z

the error is:

error FS0412: A type instantiation involves a byref type. This is not permitted by the rules of Common IL.
``
But this slight variation compiles fine:
```fsharp
type Incrementor(z) =
    abstract member Increment : int byref * int byref -> unit
    default this.Increment(i : int byref,j : int byref) =
       i <- i + z

type Decrementor(z) =
    inherit Incrementor(z)
    override this.Increment(i, j) =
        this.Increment(&i, &j)

        i <- i - z

All I’ve done is to change the target of Increment in the override from base to this (so it will stack overflow at runtime), which shows that the compiler is somehow analyzing the base call and a normal call differently (and, I believe wrongly in the former case).

@latkin latkin added the Bug label Jan 26, 2015
@dsyme
Copy link
Contributor

dsyme commented Apr 30, 2015

Duplicate of #130

@dsyme dsyme closed this as completed Apr 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants