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

Fable 4 cannot recognize generic property type parameter, when it is not declared on the property explicitly #3248

Closed
ArtemyB opened this issue Oct 31, 2022 · 7 comments

Comments

@ArtemyB
Copy link

ArtemyB commented Oct 31, 2022

Description

When a type has a property with implicit generic type parameter, Fable 4 reports an error type parameter is not defined. However F# compiler and Fable 3 handles compilation successfully.

Repro code

Example code:

type Example1 =
    abstract implicitlyGenericProperty1 : 't with get, set
    abstract implicitlyGenericProperty2 : ('t -> string) with get, set
    abstract explicitlyGenericProperty1<'t> : 't with get, set
    abstract explicitlyGenericProperty2<'t> : ('t -> string) with get, set
    abstract implicitlyGenericMethod : 't -> string
    abstract explicitlyGenericMethod<'t> : 't -> string

REPL example screenshot

REPL link

Expected and actual results

In the example above the members implicitlyGenericProperty1 and implicitlyGenericProperty2 provokes the error while the other slightly different members doesn't. The expected behavior is to have the whole code being compiled successfully as it happens with regular F# compiler and Fable 3.

Related information

  • Fable version: at least 4.0.0-theta-008, 4.0.0-theta-012, 4.0.0-theta-014
  • Operating system: Windows 10 21H1
@ArtemyB ArtemyB changed the title Fable 4 cannot recognize property's generic type parameter, when it is not declared explicitly Fable 4 cannot recognize generic property type parameter, when it is not declared on the property explicitly Oct 31, 2022
@kerams
Copy link
Contributor

kerams commented Nov 1, 2022

dotnet/fsharp#12198
fable-compiler/fable-browser#79

This is no longer allowed as it didn't make sense (produced invalid IL) in the first place.

@ArtemyB
Copy link
Author

ArtemyB commented Nov 1, 2022

@kerams so that's me who is wrong, not Fable 4 - what a twist 🤔 And just because the issue has been fixed quite recently, I don't see the error in environments other than Fable 4 as I understand. So the problem relates only to inferred property parameters -- there is nothing wrong with explicitly set generic property parameters or inferred (implicit) generic method parameters, am I right?

@kerams
Copy link
Contributor

kerams commented Nov 1, 2022

Properties may not be generic.

I don't see the error in environments other than Fable 4

Fable 4 is using the bleeding edge version of FCS, so it includes the recent fix which prohibits generic properties.

@ArtemyB
Copy link
Author

ArtemyB commented Nov 1, 2022

Properties may not be generic.

Then abstract explicitlyGenericProperty1<'t> : 't with get, set in my example should produce the error too, isn't it? However it does not now, and I've even used that fact in my Fable code as a fix of the issue.

@kerams
Copy link
Contributor

kerams commented Nov 1, 2022

Hmm, I don't know. That should not work either in my opinion. It's basically the same thing.

Doesn't work

interface X
{
   public T GetT<T> { get; }
}

Works with a class-level generic type

interface X<T>
{
   public T GetT { get; }
}

@vzarytovskii, thoughts?

@kerams
Copy link
Contributor

kerams commented Nov 2, 2022

Yeah, explicit type parameters are definitely wrong. Just try it with get only. I've submitted a PR forbidding this use case too.

@ArtemyB
Copy link
Author

ArtemyB commented Nov 2, 2022

Got it, @kerams, thank you for the clarification 👍 Most likely I wouldn't have discovered the true origin of the issue by myself any time soon. Seems like now it can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants