DEV Community

ringabout
ringabout

Posted on

My Nim Development Weekly Report (2/26)

Progress

chores

invalid module names errors have been improved, it now says that a module name must be a valid Nim identifier.

fixes the linkerexe of riscv64 in config.

csources_v2 can build the ORC-booted compiler; building now uses strict mode.

saves one unnecessary compare which is also a small regression.

closes #17864; add a test case.

use {.push warning[BareExcept]:off.} to override settings temporarily.

Nim now parses the whole module at one time

fixes #19795; fixes #11852; fixes #19974; remove parsing pipeline, Nim now parses the whole module at one time

destructor analysis

Now the destructor analysis can analyze the whole module at one time, which means the declarations won't affect the analysis of global variables.

type Vector = seq[int]

var vect: Vector = newSeq[int](5)
doAssert vect == @[0, 0, 0, 0, 0]

let vectCopy = vect
proc p(): int = 3

doAssert vect == @[0, 0, 0, 0, 0]
Enter fullscreen mode Exit fullscreen mode

You don't need to put the global statements to a function anymore. It can be run with ARC/ORC as it is.

push pragmas

push pragmas now work within functions.

proc foo(x: string, y: int, res: int) =
  {.push checks: off}
  var a: ptr char = unsafeAddr(x[y])
  {.pop.}
  if x.len > y:
    doAssert ord(a[]) == 51
  else:
    doAssert x.len + 48 == res

foo("", 0, 48)
foo("abc", 40, 51)
Enter fullscreen mode Exit fullscreen mode

fixes object with distinct defaults or initTable defaults

fixes #20695; fixes object with distinct defaults and tables.

import std/[tables, times]

block:
  block:
    type
      Default = object
        tabs: Table[string, int] = initTable[string, int]()

    let d = default(Default)
    doAssert d.tabs.len == 0

  block:
    type DjangoDateTime = distinct DateTime

    type Default = object
      data: DjangoDateTime = DjangoDateTime(DateTime())

    let x = default(Default)
    doAssert x.data is DjangoDateTime
Enter fullscreen mode Exit fullscreen mode

All of them now works.

Work in progress

Overrides =copy for PackedSets.

abolish using passes in the compiler; simplify compilation pipeline.

fixes #21326; fixes #7375; fixes #11986; fixes #9607; getAst uses type info to annotate the type of quoted variables; no more type erasures for quoted variables.

Weekly collection

https://forum.nim-lang.org/t/9908 (2/19)

Sponsorship

Many thanks to @Yepoleb, @lenis0012, @pietroppeter, @Clonkk, @mode80 for sponsoring me on GitHub.

Top comments (0)