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

ICE on explicit generic proc with dependent-typed argument #7008

Closed
RedBeard0531 opened this issue Jan 1, 2018 · 5 comments · Fixed by #24005
Closed

ICE on explicit generic proc with dependent-typed argument #7008

RedBeard0531 opened this issue Jan 1, 2018 · 5 comments · Fixed by #24005

Comments

@RedBeard0531
Copy link
Contributor

type Node[T] = object
    val: T

# Compiles fine
proc concreteProc(s: Node[cstring]; key: s.T) = discard

# Also fine
proc implicitGenericProc1(s: Node; key: s.T) = discard

# still fine
proc explicitGenericProc1[T](s: Node[T]; key: T) = discard
    
# Internal Compiler Error!
proc explicitGenericProc2[T](s: Node[T]; key: s.T) = discard
Error: internal error: cannot resolve type: Node[explicitGenericProc2.T]

Repros on 0.17.2 and devel

@genotrance
Copy link
Contributor

AssertionError now with #head. Full stack trace:

Hint: used config file 'c:\users\gt\Desktop\DL\programming\nimdevel\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: temp [Processing]
nim.nim(133)             nim
nim.nim(97)              handleCmdLine
main.nim(162)            mainCommand
main.nim(73)             commandCompileToC
modules.nim(124)         compileProject
modules.nim(71)          compileModule
passes.nim(194)          processModule
passes.nim(103)          processTopLevelStmt
sem.nim(592)             myProcess
sem.nim(560)             semStmtAndGenerateGenerics
semstmts.nim(1893)       semStmt
semexprs.nim(910)        semExprNoType
semexprs.nim(2539)       semExpr
semstmts.nim(1684)       semProc
semstmts.nim(1510)       semProcAux
semstmts.nim(1121)       semParamList
semtypes.nim(1036)       semProcTypeNode
semtypes.nim(995)        semParamType
semtypes.nim(1529)       semTypeNode
semexprs.nim(2383)       semExpr
semexprs.nim(2420)       semExpr
semexprs.nim(231)        semConv
semcall.nim(379)         inferWithMetatype
sigmatch.nim(2048)       paramTypesMatch
sigmatch.nim(337)        paramTypesMatchAux
sigmatch.nim(1643)       typeRelImpl
sigmatch.nim(366)        concreteType
system.nim(3817)         raiseAssert
system.nim(2871)         sysFatal
Error: unhandled exception: false sigmatch.nim(366) cannot resolve type: Node[explicitGenericProc2.T] [AssertionError]

@narimiran
Copy link
Member

It works for me on Nim devel v1.3.5.

@RedBeard0531, can you confirm?

@ghost
Copy link

ghost commented Jul 9, 2020

@narimiran this fails:

type Node[T] = object
    val: T

# Compiles fine
proc concreteProc(s: Node[cstring]; key: s.T) = discard

# Also fine
proc implicitGenericProc1(s: Node; key: s.T) = discard

# still fine
proc explicitGenericProc1[T](s: Node[T]; key: T) = discard
    
# Internal Compiler Error!
proc explicitGenericProc2[T](s: Node[T]; key: s.T) = discard

let n = Node[int](val: 5)
implicitGenericProc1(n, 5) # works
explicitGenericProc1(n, 5) # works
explicitGenericProc2(n, 5) # doesn't

@narimiran
Copy link
Member

narimiran commented Jan 20, 2021

@narimiran this fails:
# Internal Compiler Error!

With Nim devel 1.5.1, explicitGenericProc2(n, 5) produces Error: cannot evaluate at compile time: s, which to me looks like a good (informative) error message.

@Clyybber
Copy link
Contributor

Clyybber commented Jan 21, 2021

This should work though, reopening :)

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