My Nim Development Weekly Report (2/26)
ringabout
Posted on March 3, 2023
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
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]
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)
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
All of them now works.
Work in progress
Overrides =copy for PackedSets.
abolish using passes in the compiler; simplify compilation pipeline.
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.
Posted on March 3, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.