-
Notifications
You must be signed in to change notification settings - Fork 789
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
Immediate cyclic reference is not detected #3916
Comments
Yes, thanks, this should be detected. The fix will be to account for struct tuples somewhere around |
I have determined that when it fails to detect, it fails to match this case:
at this line (and it's not the when clause that's the problem; even without the when clause, it still does not match): But it will match this, so maybe a new rule like this can fix the issue: |
Or maybe upstream, the |
Also @vasily-kirichenko , why do we need the offending syntax That should probably be documented at https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/discriminated-unions#using-discriminated-unions-for-tree-data-structures EDIT: I guess I found the answer here: https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/tuples#interoperation-with-c-tuples If not for the need to interop with C#, surely a struct tuple would not be worth the trouble. Just use a struct record instead. |
should this code raise the error at all? [<Struct>]
type Tree =
| Empty
| Children of struct (Tree * Tree) Children is a struct tuple. that mean i can do let f () =
let e = Tree.Empty
let x = struct (e,e)
let d = Tree.Children x
d or not? this compile, but like before, fails at runtime with
should be similar to type Tree =
| Empty
| Children of (Tree * Tree) who use a Tuple, because in the first example is |
@smoothdeveloper @enricosada @vasily-kirichenko Adding this new case (ScottHutchinson@d0713da#diff-5b9ab9dd9d7133aaf23add1048742031) fixes the issue for the original test case (#3916 (comment)) |
@ScottHutchinson it looks like you may need to fold over the |
@smoothdeveloper This fold might do it. ScottHutchinson@467f529#diff-5b9ab9dd9d7133aaf23add1048742031 |
Fixed by #10645 |
This code raises error at compile time (good)
This code does not (bad, bad, bad)
but it fails at runtime:
The text was updated successfully, but these errors were encountered: