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

ByRefLike structs can be declared in Anonymous Record types #6104

Closed
cartermp opened this issue Jan 15, 2019 · 5 comments
Closed

ByRefLike structs can be declared in Anonymous Record types #6104

cartermp opened this issue Jan 15, 2019 · 5 comments
Labels
Milestone

Comments

@cartermp
Copy link
Contributor

cartermp commented Jan 15, 2019

The following compiles:

open System

let f (r: {| S: Span<int> |})=  r.S.Length

f {| S=Span<int>.Empty |}

It should not compile, because r is reference type, thus violating the rules of ByRefLike structs.

Given that we cannot declare a ByRefLike struct anonymous record, ByReflike types such as Span should not be allowed inside of an anonymous record at all.

@cartermp cartermp added this to the 16.0 milestone Jan 15, 2019
@cartermp cartermp changed the title ByRefLike-values can be declared in Anonymous Record types ByRefLike structscan be declared in Anonymous Record types Jan 15, 2019
@cartermp cartermp changed the title ByRefLike structscan be declared in Anonymous Record types ByRefLike structs can be declared in Anonymous Record types Jan 15, 2019
@cartermp cartermp modified the milestones: 16.0, 16.1 Feb 21, 2019
@cartermp cartermp modified the milestones: 16.1, 16.2 Apr 23, 2019
@cartermp cartermp modified the milestones: 16.2, Backlog Apr 30, 2019
@thinkbeforecoding
Copy link
Contributor

Or could it be auto promoted to byreflike in this case ?

@cartermp
Copy link
Contributor Author

Not in this case, no. This isn't a struct anonymous record declaration.

@thinkbeforecoding
Copy link
Contributor

True, but would it be promoted if it was:

let f (r: struct {| S: Span<int> |})= r.S.Length

??

@cartermp
Copy link
Contributor Author

In this case it could be, yes.

@dsyme
Copy link
Contributor

dsyme commented Aug 26, 2020

This has been fixed somewhere along the way

@dsyme dsyme closed this as completed Aug 26, 2020
@cartermp cartermp modified the milestones: Backlog, 16.5 Aug 26, 2020
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