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.
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 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 #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.
Overrides =copy for PackedSets.
abolish using passes in the compiler; simplify compilation pipeline.
https://forum.nim-lang.org/t/9908 (2/19)
Many thanks to @Yepoleb, @lenis0012, @pietroppeter, @Clonkk, @mode80 for sponsoring me on GitHub.
I really like the {.push checks: off} pragma. I'll use that for sure!
I am sure what default(Default) is it like new(Default)? Is default a language keyword?
It looks like "abolish using passes in the compiler" will help a little with memory use? Is Nim single pass? I though that was very hard to make a single pass compiler? Can you explain this one?
default is a magic procedure that's existed in Nim for quite some time. In 1.6 and below it'd give you a 0'd representation of the value in Nim 2.0 it'll give you a 0'd variation if you do not set defaults of fields.
type
MyType = object
a = 300
b = 400
MyOtherType = object
a, b: int
when (NimMajor, NimMinor) >= 1.9.1:
assert default(MyType) == MyType(a: 300, b: 400)
else:
assert default(MyType) == MyType()
assert default(MyOtherType == MyOtherType()
Is Nim single pass? I though that was very hard to make a single pass compiler? Can you explain this one?
No, Nim always use multiple passes to optimize the code shape. I might rephrase the title as "replaces implicit passes with explicit function calls".