fable-compiler / Fable

F# to JavaScript, TypeScript, Python, Rust and Dart Compiler
http://fable.io/
MIT License
2.9k stars 296 forks source link

Option.map is not defined when opening Fable.Import.Browser #290

Closed mastoj closed 8 years ago

mastoj commented 8 years ago

When trying to use Option.bind I get

The field, constructor or member 'map' is not defined

I haven't pinned it down to why that is, but I created a branch where it is not working, you can find the failing line here: https://github.com/mastoj/Fable/blob/2bbba7e01f1770ea05f0ddb9512541c69394136e/samples/browser/virtualdom/virtualdom.fsx#L44

alfonsogarciacaro commented 8 years ago

Sorry, I cannot reproduce the error (both Option.bind and Option.map work for me). Could you please give more details about the problem?

Thanks!

mastoj commented 8 years ago

Sorry, it should have been a number and not i. The problem is that it didn't compile since. I'll check again tomorrow on both Osx and win 10.

mastoj commented 8 years ago

The compile error on OSX is:

ERROR: F# project contains errors: The field, constructor or member 'map' is not defined (L44,7-L44,10) (virtualdom.fsx) at Fable.Client.Node.Main.parseFSharpProject (ICompiler com, Microsoft.FSharp.Compiler.SourceCodeServices.FSharpChecker checker, Microsoft.FSharp.Compiler.SourceCodeServices.FSharpProjectOptions projOptions) <0x5b62668 + 0x0035f> in :0 at Fable.Client.Node.Main.compile (ICompiler com, Microsoft.FSharp.Compiler.SourceCodeServices.FSharpChecker checker, Fable.FSharp2Fable.FSProjectInfo projInfo) <0x5b62130 + 0x00117> in :0

I updated the sample to something that should compile if map was defined.

I'll check on windows in a couple of hours.

Fable version: 0.4.4

mastoj commented 8 years ago

I updated the error branch : https://github.com/mastoj/Fable/tree/optionbinderror?files=1

mastoj commented 8 years ago

I have the same error on Windows with fable 0.4.5.

ERROR: F# project contains errors: The field, constructor or member 'map' is not defined (L44,7-L44,10) (virtualdom.fsx)

alfonsogarciacaro commented 8 years ago

Thanks for the additional info! The message F# project contains errors indicates the errors are coming from the F# compilation itself, not from Fable. In this case, unfortunately Fable.Import.Browser contains an Option member which overrides the F# Option module. The solution is not to open Fable.Import.Browser and use the full name whenever needed (e.g. Browser.window.setTimeout).

mastoj commented 8 years ago

I see. Thank you for clarifying. I should have figured that one out myself :)

On Fri, Jul 29, 2016 at 11:39 AM, Alfonso Garcia-Caro < notifications@github.com> wrote:

Thanks for the additional info! The message F# project contains errors indicates the errors are coming from the F# compilation itself, not from Fable. In this case, unfortunately Fable.Import.Browser contains an Option member which overrides the F# Option module. The solution is not to open Fable.Import.Browser and use the full name whenever needed (e.g. Browser.window.setTimeout).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fsprojects/Fable/issues/290#issuecomment-236138158, or mute the thread https://github.com/notifications/unsubscribe-auth/AAemsFII5_5ps7zcUA7KoxV7-uvFIwrVks5qaco_gaJpZM4JW99c .