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

Exception with alias type Something<'T> = 'T #906

Closed
Tarmil opened this Issue Feb 8, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@Tarmil
Member

Tarmil commented Feb 8, 2018

The following code:

type Alias<'T> = 'T
type Record<'T> = { x : Alias<'T> }

throws a compile-time exception:

WebSharper error : Global error 'not a named type' at    at <StartupCode$FSharp-Compiler-Service>.$Symbols.get_TypeDefinition@1871.Invoke(Unit unitVar0)
   at Microsoft.FSharp.Compiler.SourceCodeServices.Impl.protect[a](FSharpFunc`2 f)
   at WebSharper.Compiler.FSharp.CodeRea
       der.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.ProjectReader.cdef@817.Invoke(FSharpField f)
   at Microsoft.FSha
       rp.Collections.IEnumerator.map@114.DoMoveNext(b& )
   at Microsoft.FSharp.Collections.IEnumerator.MapEnumerator`1.System-Collections-IEnumerator-MoveNext()
   at Microsoft.FSharp.Collections.SeqModule.ToList[T](IEnumerable`1 source)
   at WebSharper.Compiler.FSharp.ProjectReader.tran
       sformClass(Lazy`1 sc, Compilation comp, ResolveFuncArgs ac, SymbolReader sr, Dictionary`2 classAnnots, TypeAnnotation parentAnnot, FSharpEntity cls, List`1 members)
   at WebSharper.Compiler.FSharp.ProjectReader.transformClass(Lazy`1 sc, Compilation comp, ResolveFuncArgs ac, SymbolRe
       ader sr, Dictionary`2 classAnnots, TypeAnnotation parentAnnot, FSharpEntity cls, List`1 members)
   at WebSharper.Compiler.FSharp.ProjectReader.transformAssembly@1088-4.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, FSharpCheckProjectResults checkResults)
   at WebSharper.Compiler.FSharp.WebSharperFSharpCompiler.Compile[a](Task`1 prevMeta, String[] argv, String pa
       th, String assemblyName)
   at WebSharper.FSharp.Program.Compile$cont@111-1(WsConfig config, String thisName, WebSharperFSharpCompiler compiler, Boolean isBundleOnly, FSharpList`1 paths, AssemblyResolver aR, Unit unitVar)
   at WebSharper.FSharp.Program.Compile$cont@64(WsConfig confi
       g, WarnSettings warnSettings, String thisName, Unit unitVar)
   at WebSharper.FSharp.Program.compileMain$cont@245(String[] argv, Unit unitVar)
   at WebSharper.FSharp.Program.main(String[] argv)

@Tarmil Tarmil added the bug label Feb 8, 2018

@Jand42

This comment has been minimized.

Member

Jand42 commented Feb 8, 2018

@Tarmil good catch. Should be solved by moving this line up https://github.com/dotnet-websharper/core/blob/master/src/compiler/WebSharper.Compiler.FSharp/CodeReader.fs#L359
I haven't thought that a type alias could be resolved to a generic type parameter, how did you stumble upon this? :)

@Tarmil

This comment has been minimized.

Member

Tarmil commented Feb 9, 2018

It came up in @cata's attempt to compile FCS with WebSharper, specifically here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment