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

[ARC] ICE with static objects #14236

Closed
ghost opened this issue May 5, 2020 · 2 comments
Closed

[ARC] ICE with static objects #14236

ghost opened this issue May 5, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented May 5, 2020

This code causes the compiler to crash with gc:arc. Found in https://github.com/nitely/nim-regex

Example

type
  MyType = object
    a: seq[int]

proc re(x: static[string]): static MyType = 
  MyType()

proc match(inp: string, rg: static MyType) = 
  doAssert rg.a.len == 0

match("ac", re"a(b|c)")

Current Output

/home/dian/.nim/compiler/nim.nim(104) nim
/home/dian/.nim/compiler/nim.nim(81) handleCmdLine
/home/dian/.nim/compiler/cmdlinehelper.nim(91) loadConfigsAndRunMainCommand
/home/dian/.nim/compiler/main.nim(196) mainCommand
/home/dian/.nim/compiler/main.nim(98) commandCompileToC
/home/dian/.nim/compiler/modules.nim(143) compileProject
/home/dian/.nim/compiler/modules.nim(84) compileModule
/home/dian/.nim/compiler/passes.nim(210) processModule
/home/dian/.nim/compiler/passes.nim(86) processTopLevelStmt
/home/dian/.nim/compiler/cgen.nim(1917) myProcess
/home/dian/.nim/compiler/cgen.nim(968) genProcBody
/home/dian/.nim/compiler/ccgstmts.nim(1561) genStmts
/home/dian/.nim/compiler/ccgexprs.nim(2666) expr
/home/dian/.nim/compiler/ccgexprs.nim(2452) genStmtList
/home/dian/.nim/compiler/ccgstmts.nim(1561) genStmts
/home/dian/.nim/compiler/ccgexprs.nim(2713) expr
/home/dian/.nim/compiler/ccgstmts.nim(1272) genTryGoto
/home/dian/.nim/compiler/ccgstmts.nim(1561) genStmts
/home/dian/.nim/compiler/ccgexprs.nim(2666) expr
/home/dian/.nim/compiler/ccgexprs.nim(2452) genStmtList
/home/dian/.nim/compiler/ccgstmts.nim(1561) genStmts
/home/dian/.nim/compiler/ccgexprs.nim(2630) expr
/home/dian/.nim/compiler/ccgcalls.nim(627) genCall
/home/dian/.nim/compiler/ccgcalls.nim(250) genPrefixCall
/home/dian/.nim/compiler/cgen.nim(596) initLocExpr
/home/dian/.nim/compiler/ccgexprs.nim(2562) expr
/home/dian/.nim/compiler/cgen.nim(1215) genProc
/home/dian/.nim/compiler/cgen.nim(1158) genProcNoForward
/home/dian/.nim/compiler/cgen.nim(1024) genProcAux
/home/dian/.nim/compiler/cgen.nim(968) genProcBody
/home/dian/.nim/compiler/ccgstmts.nim(1561) genStmts
/home/dian/.nim/compiler/ccgexprs.nim(2666) expr
/home/dian/.nim/compiler/ccgexprs.nim(2441) genStmtList
/home/dian/.nim/compiler/ccgstmts.nim(1561) genStmts
/home/dian/.nim/compiler/ccgexprs.nim(2630) expr
/home/dian/.nim/compiler/ccgcalls.nim(627) genCall
/home/dian/.nim/compiler/ccgcalls.nim(237) genPrefixCall
/home/dian/.nim/compiler/ccgcalls.nim(220) genArg
/home/dian/.nim/compiler/cgen.nim(609) initLocExprSingleUse
/home/dian/.nim/compiler/ccgexprs.nim(2659) expr
/home/dian/.nim/compiler/ccgexprs.nim(743) genAddr
/home/dian/.nim/compiler/cgen.nim(596) initLocExpr
/home/dian/.nim/compiler/ccgexprs.nim(2662) expr
/home/dian/.nim/compiler/ccgexprs.nim(800) genRecordField
/home/dian/.nim/compiler/ccgexprs.nim(777) lookupFieldAgain
/home/dian/.nim/lib/system/assertions.nim(29) failedAssertImpl
/home/dian/.nim/lib/system/assertions.nim(22) raiseAssert
/home/dian/.nim/lib/system/fatal.nim(49) sysFatal
Error: unhandled exception: /home/dian/.nim/compiler/ccgexprs.nim(777, 11) `ty.kind in {tyTuple, tyObject}`  [AssertionDefect]
$ nim -v
Nim Compiler Version 1.3.1 [Linux: amd64]
Compiled at 2020-05-05
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: e86a6d24d5ffe43e9dc7f230b80c274167376225
active boot switches: -d:release
@ghost
Copy link
Author

ghost commented May 5, 2020

The lookupFieldAgain proc gets this type for some reason:

static[MyType]((a: []))

@cooldome
Copy link
Member

cooldome commented May 6, 2020

I will have a look. Very useful testing @Yardanico, thank you.

cooldome pushed a commit that referenced this issue May 6, 2020
@Araq Araq closed this as completed in 0d8507c May 6, 2020
EchoPouet pushed a commit to EchoPouet/Nim that referenced this issue Jun 13, 2020
Co-authored-by: cooldome <ariabushenko@bk.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants