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

Can't initialize triangle const array #1781

Closed
def- opened this issue Dec 27, 2014 · 0 comments
Closed

Can't initialize triangle const array #1781

def- opened this issue Dec 27, 2014 · 0 comments
Labels
Severe VM see also `const` label

Comments

@def-
Copy link
Member

def- commented Dec 27, 2014

proc initCombinations: array[11, array[11, int]] =
  result[0]          = [0,0,0,0,0,0,0,0,0,0,0]
  result[1][1 .. 10] =   [0,0,0,0,0,0,0,0,0,0]
  result[2][2 .. 10] =     [0,0,0,0,0,0,0,0,0]
  result[3][3 .. 10] =       [0,0,0,0,0,0,0,0]
  result[4][4 .. 10] =         [0,0,0,0,0,0,0]
  result[5][5 .. 10] =           [0,0,0,0,0,0]
  result[6][6 .. 10] =             [0,0,0,0,0]

const combinations = initCombinations()

If you comment out any of the assignments in initCombinations it compiles. But now the compiler segfaults:

Traceback (most recent call last)
nim.nim(91)              nim
nim.nim(55)              handleCmdLine
main.nim(273)            mainCommand
main.nim(73)             commandCompileToC
modules.nim(204)         compileProject
modules.nim(152)         compileModule
passes.nim(193)          processModule
passes.nim(137)          processTopLevelStmt
sem.nim(415)             myProcess
sem.nim(389)             semStmtAndGenerateGenerics
semstmts.nim(1305)       semStmt
semexprs.nim(856)        semExprNoType
semexprs.nim(2138)       semExpr
semstmts.nim(443)        semConst
sem.nim(254)             semConstExpr
vm.nim(1409)             evalConstExpr
vm.nim(1406)             evalConstExprAux
vm.nim(468)              rawExecute
ast.nim(969)             len
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
FAILURE
@def- def- changed the title Initializing a const array segfaults Can't initialize triangle const array Dec 27, 2014
@Araq Araq added VM see also `const` label Severe labels Dec 27, 2014
@Araq Araq closed this as completed in 41587a5 Dec 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Severe VM see also `const` label
Projects
None yet
Development

No branches or pull requests

2 participants