-
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
Inconsistent error and warning messaging in VS while using [<TailCall>] plus unexpected error while using [<TailCall>] #16330
Comments
The first case can be because compiler is newer than tooling in VS (vs lags behind in other words). So, when full build happens, diagnostics from compiler are shown, and then when typecheck happens it rewrites output. But it's only theory. Diagnostics in VS also may differ due to error recovery difference. Not sure what's happening in second case though |
The second part, where you get a warning for |
Yes, I know about that, but why an error is raised, not just a warning? I apologise for not suggesting the expected result in the text of the raised issue. |
Hey @MiroslavHustak , [<TailCall>]
let rec internal bind f program =
match program with
| Free x -> Free (mapI (bind f) x)
| Pure x -> f x
[<TailCall>]
let rec internal nXor operands =
match operands with
| [] -> false
| x::xs -> (x && not (nXor xs)) || ((not x) && (nXor xs)) These are not tail-recursive definitions, so it's okay to get a warning for them. Regarding the warning for your let rec interpret config io xxx =
... and later do a match xxx with
| Pure x -> x
... That should help turning it into a tailrec definition. |
I don't think it's the But yes, @dawedawe is right that making the last parameter explicit in the outer One could argue that the compiler should treat the two forms the same (like it does when there are no intermediate definitions in something like |
Thanx all for trying to help :-). Actually, my primary aim was not to make the recursive functions tail-recursive (although I appreciate your help), but to test the new fantastic feature (IMHO extremely useful for everyone) and see whether the warnings do appear. The inconsistency of the warning messages (they sometimes appeared, other times not) was the first issue, the second one was that the If it should stay like that, perhaps it will be fine to mention it in the documentation. Also, perhaps it might be useful to mention that local functions cannot be annotated with I wish I could help you somehow, but I am not a very experienced programmer :-(. |
Well, local functions can just never have any attributes. It's a weak spot of the language, I agree. Regarding the error: I was able to reproduce |
@MiroslavHustak |
@dawedawe @brianrourkeboll Anyway, I was curious what would happen when I made the recursive call "not optimised" (#6984) for the now tail-recursive function - applying the piping operator |>. And I received neither the FS0251 error, nor the FS3569 warning. I am baffled. Let me summarise the behaviour of the non-tail recursive and tail-recursive
|
@MiroslavHustak As your second
By using |
Yeah, now I got the point. I've got the big picture now. Thanx very much for your explanation. This information is IMHO important and worth including in some textbook :-). |
- use GetValReprTypeInFSharpForm instead of GetTopTauTypeInFSharpForm - fixes dotnet#16330 - add regression tests
[<TailCall>]
in my app:After a build, the aforementioned code sometimes triggers warning messages (see below) in the Error List, other times not.
After a build, the aforementioned code sometimes triggers warning messages (see below) in the Output, other times not.
warning FS3569: The member or function 'bind' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way.
warning FS3569: The member or function 'nXor' has the 'TailCallAttribute' attribute, but is not being used in a tail recursive way.
To reproduce, you may use my entire VS solution (the functions in question are in the files Helpers.fs and FreeMonads.fs). 54 MB.
[<TailCall>]
in the following code invokes an error message. I do not see any reason why. UPDATE: A warning is expected instead.Again, the messaging is inconsistent. After a build, the aforementioned code sometimes triggers an error message (see below) both in the Output and Error List, other times only in the Output.
error FS0251: Invalid member signature encountered because of an earlier error
To reproduce, you may use my entire VS solution (the function in question is in the file Helpers.fs). 54 MB.
Windows 10 Pro, version 22H2
.NET 8
VS, version 17.8.0
The text was updated successfully, but these errors were encountered: