remove nosinks hacks from compiler.
fixes sinkinference documentation, which has been disabled.
fixes #19291; implements wasMoved hook.
You can now register a wasMoved hook.
type
Game = object
proc `=wasMoved`(x: var Game) {.error.}
fixes #20139; hash types based on custom paths.
Now the object type with the same name in the same file name but resides in different directories won't conflict with each other anymore. The PR takes the path of the type into consideration, which prevents conflicts.
static:
for i in '1' .. '2':
var s: set[char]
doAssert s == {}
incl(s, i)
The variable s wasn't initialized properly in the loop. It caused s to keep the old value after the first iteration. My solution is to initialize s each time the var section is executed, which is reset for every iteration.
import macros
macro foo(body: untyped): untyped =
let a = body.lineInfoObj()
result = quote do:
echo `a`
foo:
let c = 1
The VM is an untyped executor, which erases types of expressions after execution. In this case, a is evaluated in the VM, which loses its type, namely LineInfo after evaluation. So we should collect the type information and annotate the type of a when expanding quote do. I store the type information in the parameters of the dummy templates used by quote do, which is used to restore the type of quoted variables.
proc processPipeline(graph: ModuleGraph; semNode: PNode; bModule: PPassContext): PNode =
case graph.pipelinePass
of CgenPass:
result = semNode
if bModule != nil:
genTopLevelStmt(BModule(bModule), result)
of JSgenPass:
when not defined(leanCompiler):
result = processJSCodeGen(bModule, semNode)
of GenDependPass:
result = addDotDependency(bModule, semNode)
of SemPass:
result = graph.emptyNode
of Docgen2Pass, Docgen2TexPass:
when not defined(leanCompiler):
result = processNode(bModule, semNode)
of Docgen2JsonPass:
when not defined(leanCompiler):
result = processNodeJson(bModule, semNode)
of EvalPass, InterpreterPass:
result = interpreterCode(bModule, semNode)
of NonePass:
doAssert false, "use setPipeLinePass to set a proper PipelinePass"
The processPipeline explicitly calls the code generator, which makes the code more clear. It is the second step towards to remove forward declaration.
https://forum.nim-lang.org/t/9908 (2/19) https://forum.nim-lang.org/t/9940 (2/26)
I have created a matrix space for contributions to the official Nim projects. If you are already a contributor of the official Nim projects, welcome to this space to discuss contributions. If you are willing to take up some quests for fun, I have prepared a list for you, which contains a few contribution-friendly issues.
Many thanks to @Yepoleb, @lenis0012, @pietroppeter, @Clonkk, @mode80, @Phil, @CxPlanner, @shirleyquirk, @elcritch, @geotre, @thinkwelltwd, @xrfez, @enthus1ast for sponsoring me on GitHub.
This is awesome thank you!
Do you have an idea of how far we are from the official Nim 2.0 release?