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

FsToolkit.ErrorHandling errors on 4.0.0-theta-015 #3259

Closed
TheAngryByrd opened this issue Nov 9, 2022 · 6 comments
Closed

FsToolkit.ErrorHandling errors on 4.0.0-theta-015 #3259

TheAngryByrd opened this issue Nov 9, 2022 · 6 comments

Comments

@TheAngryByrd
Copy link

TheAngryByrd commented Nov 9, 2022

Description

👋 I'm going thru the process of updating FsToolkit.ErrorHandling to F# 7 however, I'm getting this error when compiling and running the tests.

Started Fable compilation...
Fable compilation finished in 2605ms                                    

.\tests\FsToolkit.ErrorHandling.Tests\Expect.fs(50,28): (50,44) error FABLE: Cannot get type info of generic parameter $a. Fable erases generics at runtime, try inlining the functions so generics can be resolved at compile time.
Compilation failed
Finished (Failed) 'RunFableTests' in 00:00:17.2451839

This code was working before, I'm not sure what changed. I tried inlining a few of the functions in the module but it didn't seem to change anything.

Any pointers would be helpful! Thanks :)

Repro code

PR of FsToolkit

To run build either build.cmd or build.bash should initiate it.

Expected and actual results

Please provide the expected and actual results.

Related information

dotnet fable --version
4.0.0-theta-015
  • Fable version: dotnet fable --version
  • Operating system
@TheAngryByrd
Copy link
Author

Well I guess inlining everything in the file seems to work. I don't mind doing it but feels like a weird change to me. Feel free to close if this is by design.

@alfonsogarciacaro
Copy link
Member

Thanks a lot for reporting @TheAngryByrd! Our goal is to make every code compilable with Fable 3 also compilable with Fable 4 as-is, so ideally we shouldn't need to introduce code changes only for Fable 4.

Although I'm surprised about two things:

  • The need to inline functions to get type info from generics has been a Fable requirement since the beginning, so you should have seen it in Fable 3 too.
  • I don't see any function in Expect.fs requiring type info from a generic so the error shouldn't be raised 🤔 Do you know of any other place in the code that uses type info from generics?

@TheAngryByrd
Copy link
Author

I don't see any function in Expect.fs requiring type info from a generic so the error shouldn't be raised 🤔 Do you know of any other place in the code that uses type info from generics?

No I do not. I haven't tried, but looking again, I wonder if it's related to the sprintf "%A" type code?

@alfonsogarciacaro
Copy link
Member

Thanks to your link I could reproduce and found the issue: it's the same function, because Fable.Mocha.Expect.equal does get the type info from the generic. Only inlining that function seems to help.

Still, I'm not sure why this issue didn't happen before and why the line number in the error log is so off. Maybe it's because of the conditional compilation with #if FABLE_COMPILER, but I thought the actual line numbers were kept in that case.

@TheAngryByrd
Copy link
Author

I'm not sure why this issue didn't happen before

I was on 3.7.1 previously. Perhaps that wasn't introduced yet? 🤷‍♂️

@alfonsogarciacaro
Copy link
Member

I was on 3.7.1 previously. Perhaps that wasn't introduced yet? 🤷‍♂️

I'd have to build with 3.7.1 to see what's the code compiled, but I doubt it because resolving generics at compile time has been a feature since the beginning.

In any case, I've sent a PR to try to fix the build, including potential problems with the SDK. Can you please check? demystifyfp/FsToolkit.ErrorHandling#196

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