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

Term write rule crash compiler. #7972

Closed
slangmgh opened this issue Jun 6, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@slangmgh
Copy link
Contributor

commented Jun 6, 2018

The following code quit the compiler.

import chronicles, terminal, os, strformat

proc sleep_check_ctrl_c(t: int) =
   const sleep_time = 1000
   var t = t
   let pout = stderr
   if t > 0: sleep(t)

   pout.write(ansiResetCode)
   pout.write("\e[2K")
   #let stylePrefix = "\e["
   #pout.write(fmt"{stylePrefix}0G")
   pout.write("\e[?25h")

chronicles is needed to make the compiler crash. it is from status-im/chronicles.

And if we change the code a little bit, like uncomment the last two line, or delete the last line, or delete the line 'const sleep_time = 1000', compile is fine.

@Araq

This comment has been minimized.

Copy link
Member

commented Jun 6, 2018

Well ok, but for a test case I need a version without dependency on status-im/chronicles.

@slangmgh

This comment has been minimized.

Copy link
Contributor Author

commented Jun 7, 2018

It is the term write rule.
The following code crash the compiler:

import terminal

template optimizeLogWrites*{
  write(f, x)
  write(f, y)
}(x, y: string{lit}, f: File) =
  write(f, x & y)

proc foo() =
   const N = 1
   stdout.write("")
   stdout.write("")

@slangmgh slangmgh changed the title Some code crash compiler, I cannot specify the characteristic of the code. Term write rule crash compiler. Jun 7, 2018

@andreaferretti andreaferretti added the Crash label Jun 7, 2018

@genotrance

This comment has been minimized.

Copy link
Contributor

commented Sep 12, 2018

Still crashes with #head, full stacktrace below.

-------- SNIPPET --------
import terminal

template optimizeLogWrites*{
  write(f, x)
  write(f, y)
}(x, y: string{lit}, f: File) =
  write(f, x & y)

proc foo() =
   const N = 1
   stdout.write("")
   stdout.write("")
-------------------------

-------- OUTPUT --------
Hint: used config file 'c:\users\gt\Desktop\DL\programming\nimdevel\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: temp [Processing]
Hint: terminal [Processing]
Hint: macros [Processing]
Hint: strformat [Processing]
Hint: parseutils [Processing]
Hint: unicode [Processing]
Hint: strutils [Processing]
Hint: math [Processing]
Hint: bitops [Processing]
Hint: algorithm [Processing]
Hint: colors [Processing]
Hint: tables [Processing]
Hint: hashes [Processing]
Hint: winlean [Processing]
Hint: dynlib [Processing]
Hint: os [Processing]
Hint: times [Processing]
Hint: options [Processing]
Hint: typetraits [Processing]
Hint: ospaths [Processing]
temp.nim(10, 4) Hint: optimizeLogWrites("", "", stdout) --> 'write(stdout, "")' [Pattern]
temp.nim(10, 10) Error: internal error: transformConstSection
No stack traceback available
To create a stacktrace, rerun compilation with ./koch temp c <file>
------------------------

-------- NIMTEMP --------
Hint: used config file 'c:\users\gt\Desktop\DL\programming\nimdevel\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: temp [Processing]
Hint: terminal [Processing]
Hint: macros [Processing]
Hint: strformat [Processing]
Hint: parseutils [Processing]
Hint: unicode [Processing]
Hint: strutils [Processing]
Hint: math [Processing]
Hint: bitops [Processing]
Hint: algorithm [Processing]
Hint: colors [Processing]
Hint: tables [Processing]
Hint: hashes [Processing]
Hint: winlean [Processing]
Hint: dynlib [Processing]
Hint: os [Processing]
Hint: times [Processing]
Hint: options [Processing]
Hint: typetraits [Processing]
Hint: ospaths [Processing]
temp.nim(10, 4) Hint: optimizeLogWrites("", "", stdout) --> 'write(stdout, "")' [Pattern]
temp.nim(10, 10) Error: internal error: transformConstSection
Traceback (most recent call last)
nim.nim(107)             nim
nim.nim(71)              handleCmdLine
cmdlinehelper.nim(84)    loadConfigsAndRunMainCommand
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(1936)       semStmt
semexprs.nim(920)        semExprNoType
semexprs.nim(2541)       semExpr
semstmts.nim(1727)       semProc
semstmts.nim(1658)       semProcAux
transf.nim(1031)         transformBody
transf.nim(972)          processTransf
transf.nim(957)          transform
transf.nim(111)          transformSons
transf.nim(921)          transform
transf.nim(210)          transformConstSection
msgs.nim(521)            internalError
msgs.nim(492)            liMessage
msgs.nim(321)            handleError
msgs.nim(311)            quit
-------------------------

-------- VERSION --------
Nim Compiler Version 0.18.1 [Windows: i386]
Compiled at 2018-09-12
Copyright (c) 2006-2018 by Andreas Rumpf

git hash: 87955eaf3048bd6b69a988ac330f9d35b2cfa39e
active boot switches: -d:release
-------------------------

@Araq Araq closed this in ec4985a Oct 18, 2018

narimiran added a commit to narimiran/Nim that referenced this issue Oct 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.