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 #130

Closed
KevinRansom opened this issue Jan 26, 2015 · 4 comments
Closed

Base calls with byref arguments are not analyzed correctly #130

KevinRansom opened this issue Jan 26, 2015 · 4 comments
Labels
Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.

Comments

@KevinRansom
Copy link
Member

From Codeplex opened by kvb

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:

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).

@yukitos
Copy link

yukitos commented Jan 27, 2015

Wrong title?

@latkin
Copy link
Contributor

latkin commented Jan 27, 2015

I've corrected the bug info, thanks.

@latkin latkin added the Bug label Jan 27, 2015
@yukitos
Copy link

yukitos commented Jan 27, 2015

:)

@dsyme dsyme added this to the VS 2015 milestone Apr 30, 2015
@dsyme dsyme added the pri-3 label May 9, 2015
@dsyme dsyme added the V.Next label May 20, 2015
@latkin latkin modified the milestones: VS 2015, vNext May 22, 2015
@latkin latkin modified the milestones: F# 4.0 Update 1, vNext Aug 4, 2015
@latkin latkin removed the V.Next label Aug 4, 2015
@KevinRansom KevinRansom removed the pri-3 label Dec 4, 2015
@dsyme dsyme added Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. Area-Compiler labels Jan 8, 2016
@dsyme
Copy link
Contributor

dsyme commented Jan 8, 2016

Closing in favour of master bug #862

@dsyme dsyme closed this as completed Jan 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Projects
None yet
Development

No branches or pull requests

5 participants