andyarvanitis / purescript-native

A native compiler backend for PureScript (via C++ or Golang)
http://purescript.org
Other
629 stars 40 forks source link

Missing module Unsafe.Coerce? #52

Closed PilchardFriendly closed 4 years ago

PilchardFriendly commented 4 years ago

I've only been using go for 30 minutes, and purescript for 3 days, so I'm not quite sure what to do next.... please go easy on me...

I've got spago to run the build (removed my GOPATH, and it all worked well). I've got a Main in the project root.

spago version
0.14.0
psgo --version
master, commit b5b1635138ba5e3f5dc90df77e3a2fb043e1a7e1

When I run ./Main it dumps at my option parser -> Data.Exists -> Unsafe.Coerce

What else can I tell you?

Stacktrace:


panic: Foreign value 'unsafeCoerce' for purescript module 'Unsafe.Coerce' not found

goroutine 1 [running]:
github.com/purescript-native/go-runtime.Get(...)
    /Users/ndrew/go/pkg/mod/github.com/purescript-native/go-runtime@v0.1.0/purescript.go:40
project.localhost/purescript-native/output/Unsafe%2eCoerce.PS__unsafeCoerce.func1()
    /Users/ndrew/Code/shokinin/shokinin-20/output/Unsafe.Coerce/Unsafe_Coerce.go:24 +0x188
sync.(*Once).doSlow(0x1518648, 0x12d32f8)
    /usr/local/opt/go/libexec/src/sync/once.go:66 +0xec
sync.(*Once).Do(...)
    /usr/local/opt/go/libexec/src/sync/once.go:57
project.localhost/purescript-native/output/Unsafe%2eCoerce.PS__unsafeCoerce(0x12745a0, 0x12d2cc0)
    /Users/ndrew/Code/shokinin/shokinin-20/output/Unsafe.Coerce/Unsafe_Coerce.go:23 +0x65
project.localhost/purescript-native/output/Data%2eExists.PS__mkExists(...)
    /Users/ndrew/Code/shokinin/shokinin-20/output/Data.Exists/Data_Exists.go:17
project.localhost/purescript-native/output/Options%2eApplicative%2eTypes.PS__parserApply.func2.1(0x1279d20, 0xc000155470, 0x12745a0, 0xc00014dde0)
    /Users/ndrew/Code/shokinin/shokinin-20/output/Options.Applicative.Types/Options_Applicative_Types.go:1163 +0x5e
github.com/purescript-native/go-runtime.Apply(0x12745a0, 0x12d0f28, 0xc00015fcf8, 0x3, 0x3, 0x1279d20, 0xc000155a10)
    /Users/ndrew/go/pkg/mod/github.com/purescript-native/go-runtime@v0.1.0/release.go:9 +0x87
project.localhost/purescript-native/output/Control%2eApply.PS__lift2.func1.1.1.1(0x1279d20, 0xc000155470, 0x12745a0, 0xc00010a880)
    /Users/ndrew/Code/shokinin/shokinin-20/output/Control.Apply/Control_Apply.go:66 +0x280
github.com/purescript-native/go-runtime.Apply(0x12745a0, 0x12d2888, 0xc00015ff28, 0x3, 0x3, 0x12745a0, 0x12d2fa0)
    /Users/ndrew/go/pkg/mod/github.com/purescript-native/go-runtime@v0.1.0/release.go:9 +0x87
main.PS__main(0x126afa0, 0xc00006a058)
    /Users/ndrew/Code/shokinin/shokinin-20/output/Main/Main.go:117 +0x313
main.main()
    /Users/ndrew/Code/shokinin/shokinin-20/output/Main/Main.go:128 +0x22```
PilchardFriendly commented 4 years ago

Ok - my /purescript-native/ffi_loader.go was missing _ "github.com/purescript-native/go-ffi/purescript-unsafe-coerce"

I've added that, and the problem changed:

github.com/purescript-native/go-runtime.Run(...)
    /Users/ndrew/go/pkg/mod/github.com/purescript-native/go-runtime@v0.1.0/release.go:16
github.com/purescript-native/go-ffi/purescript-effect.init.0.func2.1.1(0x12747a0, 0xc00016b470)
    /Users/ndrew/go/pkg/mod/github.com/purescript-native/go-ffi@v0.0.0-20191015034244-22b13919279c/purescript-effect/Effect.go:19 +0x4b
github.com/purescript-native/go-runtime.Run(...)
    /Users/ndrew/go/pkg/mod/github.com/purescript-native/go-runtime@v0.1.0/release.go:16
github.com/purescript-native/go-ffi/purescript-effect.init.0.func2.1.1(0xc00016b4a0, 0x12747a0)
    /Users/ndrew/go/pkg/mod/github.com/purescript-native/go-ffi@v0.0.0-20191015034244-22b13919279c/purescript-effect/Effect.go:19 +0xbd
github.com/purescript-native/go-runtime.Run(...)
    /Users/ndrew/go/pkg/mod/github.com/purescript-native/go-runtime@v0.1.0/release.go:16
github.com/purescript-native/go-ffi/purescript-effect.init.0.func2.1.1(0x12747a0, 0xc00016b5c0)
    /Users/ndrew/go/pkg/mod/github.com/purescript-native/go-ffi@v0.0.0-20191015034244-22b13919279c/purescript-effect/Effect.go:19 +0x53
github.com/purescript-native/go-runtime.Run(...)
    /Users/ndrew/go/pkg/mod/github.com/purescript-native/go-runtime@v0.1.0/release.go:16
github.com/purescript-native/go-ffi/purescript-effect.init.0.func2.1.1(0x126b920, 0xc0000164d0)
    /Users/ndrew/go/pkg/mod/github.com/purescript-native/go-ffi@v0.0.0-20191015034244-22b13919279c/purescript-effect/Effect.go:19 +0xbd
github.com/purescript-native/go-runtime.Run(...)
    /Users/ndrew/go/pkg/mod/github.com/purescript-native/go-runtime@v0.1.0/release.go:16
github.com/purescript-native/go-ffi/purescript-effect.init.0.func2.1.1(0x126b920, 0xc0000164d0)
    /Users/ndrew/go/pkg/mod/github.com/purescript-native/go-ffi@v0.0.0-20191015034244-22b13919279c/purescript-effect/Effect.go:19 +0x53
github.com/purescript-native/go-runtime.Run(...)
    /Users/ndrew/go/pkg/mod/github.com/purescript-native/go-runtime@v0.1.0/release.go:16
main.PS__main.func2(0x126b5a0, 0xc00016b650)
    /Users/ndrew/Code/shokinin/shokinin-20/output/Main/Main.go:120 +0xb2
github.com/purescript-native/go-runtime.Run(...)
    /Users/ndrew/go/pkg/mod/github.com/purescript-native/go-runtime@v0.1.0/release.go:16
main.main()
    /Users/ndrew/Code/shokinin/shokinin-20/output/Main/Main.go:128 +0x3f
PilchardFriendly commented 4 years ago

The offending line is below. So - I'll go and have a look at ffi js code, and port it, right?


 var options Any = Apply(Options_Applicative_Extra.PS__execParser(), Apply(Options_Applicative_Builder.PS__info(), Apply(Options_Applicative_Internal_Utils.PS__apApplyFlipped(), Options_Applicative_Types.PS__parserApply(), PS__programOptions(), Options_Applicative_Extra.PS__helper()), Apply(Data_Semigroup.PS__append(), Options_Applicative_Builder.PS__infoModSemigroup(), Options_Applicative_Builder.PS__fullDesc(), Apply(Data_Semigroup.PS__append(), Options_Applicative_Builder.PS__infoModSemigroup(), Apply(Options_Applicative_Builder.PS__progDesc(), "Shokinin 20"), Apply(Options_Applicative_Builder.PS__header(), "Get to the food truck!")))))
    return func() Any {
        var seed Any = Run(Random_LCG.PS__randomSeed())
        var opts Any = Run(options)
        var logs Any = Run(Apply(Teletype.PS__runTeletype(), Apply(PS__program(), Apply(strategy, opts), seed)))
        return logs
    }```
andyarvanitis commented 4 years ago

I've added that, and the problem changed:

Sorry, I don't see error message (for the panic); I'm guessing some of the output is missing?

Otherwise, I'm guessing you're correct in identifying some missing implementations.