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

error FSHARP: This runtime coercion or type test from type 'a to string #13

Open
nojaf opened this issue Nov 14, 2018 · 4 comments
Open

error FSHARP: This runtime coercion or type test from type 'a to string #13

nojaf opened this issue Nov 14, 2018 · 4 comments

Comments

@nojaf
Copy link

@nojaf nojaf commented Nov 14, 2018

I'm getting some problems when compiling with Fable2.

I try

module FableProject.Tests

open Fable.Import.Jest
open Matchers
open FableProject.Library

test "Basic sum test" <| fun () ->
    sum 7 4 == 11

And I get

C:/temp/fable-template/Content/.fable/Fable.Import.Jest.1.9.0/Matchers.fs(75,69): (75,107) error FSHARP: This runtime coercion or type test from type
    'a
 to
    string
involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed.
C:/temp/fable-template/Content/.fable/Fable.Import.Jest.1.9.0/Matchers.fs(75,132): (75,170) error FSHARP: This runtime coercion or type test from type
    'a
 to
    string
involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed.
C:/temp/fable-template/Content/.fable/Fable.Import.Jest.1.9.0/Matchers.fs(76,70): (76,108) error FSHARP: This runtime coercion or type test from type
    'a
 to
    string
involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed.
C:/temp/fable-template/Content/.fable/Fable.Import.Jest.1.9.0/Matchers.fs(76,128): (76,166) error FSHARP: This runtime coercion or type test from type
    'a
 to
    string
involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed.
C:/temp/fable-template/Content/.fable/Fable.Import.Jest.1.9.0/Matchers.fs(87,2): (87,42) error FSHARP: This runtime coercion or type test from type
    'a
 to
    unit
involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed.
C:/temp/fable-template/Content/.fable/Fable.Import.Jest.1.9.0/Matchers.fs(90,2): (90,41) error FSHARP: This runtime coercion or type test from type
    'a
 to
    unit
involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed.
fable: Compilation failed at 13:43:25 (11.890 s)
error Command failed with exit code 1.

Not entirely sure what is going wrong here, I hope it is related to Fable two. Maybe the bindings should be revisited.

Problem seems to be related to :?> string.
See R75
Error doesn't occur when sprintf is changed to:

| true -> createObj ["message" ==> (sprintf "Expected %A not to equal %A" (this?utils?printExpected(x)) (this?utils?printReceived(y))); "pass" ==> true]

Same with :?> unit on R90
Is resolved by

let toEqualNone (x):unit =
  expect.Invoke(x)?toEqualNone() |> ignore
@xdaDaveShaw
Copy link

@xdaDaveShaw xdaDaveShaw commented Nov 29, 2018

This has causing my CI process to fail since I left the dotnet-fable tool and went back to NPM - before it errored, but carried on. But now my Fake script sees it as an error and fails.

Thanks @nojaf for a working version of the Matchers.fs.
I've hacked it into my build pipeline for now. Overriding the version in the nuget cache before calling fable-splitter.

You can see my changes here:
xdaDaveShaw/XmasList@34f5a07

@nojaf
Copy link
Author

@nojaf nojaf commented Nov 29, 2018

Hi @xdaDaveShaw , I just downloaded my fixes from github via paket. See paket.dependencies.

Maybe that can work for you too.

@xdaDaveShaw
Copy link

@xdaDaveShaw xdaDaveShaw commented Nov 29, 2018

I was trying to think how to do that, but wasn't sure how hard / easy it would be to remove the package and use the Files. Wasn't as bad as I feared.

@inosik
Copy link

@inosik inosik commented Feb 1, 2019

I guess it has something to do with the fact that Fable prepends the sources of NuGet packages into your project which lets the F# compiler behave somewhat differently. I think this can be solved if you use the !! operator instead of trying casting to string, something like this (the first error from your log from above):

- createObj ["message" ==> (sprintf "Expected " + (this?utils?printExpected(x) :?> string) + " not to equal " +  (this?utils?printReceived(y) :?> string)); "pass" ==> true]
+ createObj ["message" ==> (sprintf "Expected " + !! (this?utils?printExpected(x)) + " not to equal " +  !! (this?utils?printReceived(y))); "pass" ==> true]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants