You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an existing project which I tried to create a WebSharper library from. I created a new WebSharper library from the Visual Studio template and put my code there. However, compilation fails with the error Global error 'not a named type' at ... (full error at bottom).
The error mesesage doesn't tell where the error is coming from, so I had to remove code file by file until I found one of the problematic parts (is there an easier way to do this?).
Minimal reproduction example (tested with WebSharper v.4.2.3.236):
Create new "WebSharper 4 Library" F# project in Visual Studio
Note that there is no JavaScript annotation, so I would expect the code to compile even if WebSharper doesn't know how to generate JavaScript for this class. However, this piece of code breaks compilation and gives a very unhelpful error message.
There seem to be also other kind of cases which will cause this same error. However, it is very difficult to create minimal examples of these if I don't even know which file causes the error except by trial and error.
Full error message:
Error FS9001 Global error 'not a named type' at at <StartupCode$FSharp-Compiler-Service>.$Symbols.get_TypeDefinition@1892.Invoke(Unit unitVar0)
at Microsoft.FSharp.Compiler.SourceCodeServices.Impl.protect[a](FSharpFunc`2 f)
at WebSharper.Compiler.FSharp.CodeReader.SymbolReader.ReadTypeSt(Boolean markStaticTP, FSharpMap`2 tparams, FSharpType t)
at Microsoft.FSharp.Collections.Internal.IEnumerator.map@74.DoMoveNext(b& )
at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext()
at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
at WebSharper.Compiler.FSharp.CodeReader.SymbolReader.ReadTypeSt(Boolean markStaticTP, FSharpMap`2 tparams, FSharpType t)
at Microsoft.FSharp.Collections.Internal.IEnumerator.map@74.DoMoveNext(b& )
at Microsoft.FSharp.Collections.Internal.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext()
at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
at WebSharper.Compiler.FSharp.CodeReader.SymbolReader.ReadTypeSt(Boolean markStaticTP, FSharpMap`2 tparams, FSharpType t)
at WebSharper.Compiler.FSharp.CodeReader.SymbolReader.ReadType(FSharpMap`2 tparams, FSharpType t)
at WebSharper.Compiler.FSharp.CodeReader.SymbolReader.ReadMember(FSharpMemberOrFunctionOrValue x)
at WebSharper.Compiler.FSharp.ProjectReader.getAnnot@254(SymbolReader sr, FSharpEntity cls, TypeAnnotation annot, Dictionary`2 annotations, FSharpMemberOrFunctionOrValue x)
at WebSharper.Compiler.FSharp.ProjectReader.transformClass(Lazy`1 sc, Compilation comp, ResolveFuncArgs ac, SymbolReader sr, Dictionary`2 classAnnots, TypeAnnotation parentAnnot, FSharpEntity cls, List`1 members)
at WebSharper.Compiler.FSharp.ProjectReader.transformAssembly@1095-3.Invoke(FSharpImplementationFileContents file)
at Microsoft.FSharp.Collections.SeqModule.Iterate[T](FSharpFunc`2 action, IEnumerable`1 source)
at WebSharper.Compiler.FSharp.ProjectReader.transformAssembly(Compilation comp, String assemblyName, WsConfig config, FSharpCheckProjectResults checkResults)
at WebSharper.Compiler.FSharp.WebSharperFSharpCompiler.Compile[a](Task`1 prevMeta, String[] argv, WsConfig config, String assemblyName)
at WebSharper.FSharp.Program.Compile$cont@110-1(WsConfig config, String thisName, WebSharperFSharpCompiler compiler, Boolean isBundleOnly, FSharpList`1 paths, AssemblyResolver aR, Unit unitVar)
at WebSharper.FSharp.Program.Compile$cont@61(WsConfig config, WarnSettings warnSettings, String thisName, Unit unitVar)
at WebSharper.FSharp.Program.compileMain$cont@255(String[] argv, Unit unitVar)
at WebSharper.FSharp.Program.main(String[] argv) FUtil FSC 1 Active
The text was updated successfully, but these errors were encountered:
Thanks for the report! The WebSharper compiler does look through non JavaScript-annotated types too, because there are some basic support for even non-annotated records/unions (translating them to plain objects).
So the problem is that the F# type reader of WS is not prepared to see a Measure generic parameter, which properly should be ignored (Measure is erased even in .NET runtime).
I have an existing project which I tried to create a WebSharper library from. I created a new WebSharper library from the Visual Studio template and put my code there. However, compilation fails with the error
Global error 'not a named type' at ...
(full error at bottom).The error mesesage doesn't tell where the error is coming from, so I had to remove code file by file until I found one of the problematic parts (is there an easier way to do this?).
Minimal reproduction example (tested with WebSharper v.4.2.3.236):
Note that there is no JavaScript annotation, so I would expect the code to compile even if WebSharper doesn't know how to generate JavaScript for this class. However, this piece of code breaks compilation and gives a very unhelpful error message.
There seem to be also other kind of cases which will cause this same error. However, it is very difficult to create minimal examples of these if I don't even know which file causes the error except by trial and error.
Full error message:
The text was updated successfully, but these errors were encountered: