The parser has been changed, now you need to use type RecordType = (tuple or object) ro declare types classes starting with tuple or object instead of type RecordType = tuple or object.
fixes #14255; Crash in compiler when using system.any by accident.
var a = newSeq[bool](1000)
if any(a):
echo "ok?"
Now it gives proper an error message => "Error: illegal type conversion to 'any'".
fixes #3770; templates with untyped parameters resolve private fields wrongly in generics.
type
Noice* = object
hidden: int
template jjj*: Noice =
Noice(hidden: 15)
# bug #3770
import m3770
doAssert $jjj() == "(hidden: 15)" # works
proc someGeneric(_: type) =
doAssert $jjj() == "(hidden: 15)"
someGeneric(int)
Now the example compiles.
WIP adds compiler support for object construction shorthand.
type
Vector = object
a: int = 999
b, c: int
block: # positional construction
## It specifies all the unnamed fields
var x = Vector(1, 2, 3)
doAssert x.b == 2
block:
## unnamed fields can be mixed with named fields
block:
var x = Vector(a: 1, 2, 3)
doAssert x.c == 3
block:
var x = Vector(1, b: 2, 3)
doAssert x.c == 3
block:
var x = Vector(1, 2, c: 3)
doAssert x.c == 3
block:
## Object variants support unnamed fields for tags, which should be known at the compile time.
type
Color = enum
Red, Blue, Yellow
Factor = object
id: int
case flag: Color
of Red:
num: int
of Blue, Yellow:
done: bool
name: string
block:
var x = Factor(1, Red, 2, "1314")
doAssert x.num == 2
block:
var x = Factor(1, Blue, true, "1314")
doAssert x.done == true
block:
var x = Factor(1, Yellow, false, "1314")
doAssert x.done == false
type
Ciao = object
id: int
case flag: bool = false
of true:
num: int
of false:
done: bool
name: string
block:
var x = Ciao(12, false, false, "123")
doAssert x.done == false
block:
var x = Ciao(12, flag: true, 1, "123")
doAssert x.num == 1
https://forum.nim-lang.org/t/9908 (2/19)
https://forum.nim-lang.org/t/9940 (2/26)
https://forum.nim-lang.org/t/9970 (3/5)
https://forum.nim-lang.org/t/9989 (3/12)
https://forum.nim-lang.org/t/10024 (3/19)
Following The Roadmap 2023 for community building , you could join us in the matrix space where we discuss how to build a community. We appreciate doable suggestions and helps, such as improving the workflow, implementing the roadmap, suggesting doable tasks, reviewing code from contributors. United we stand. We shall work together to make the community thrive.
Many thanks to @Yepoleb, @lenis0012, @pietroppeter, @Clonkk, @mode80, @Phil, @CxPlanner, @shirleyquirk, @elcritch, @geotre, @thinkwelltwd, @xrfez, @enthus1ast, @piertoni, @Dnanilem, @gemath for sponsoring me on GitHub.
Ringabout, thank you for all of their hard work and for keeping us updated! Your efforts are truly appreciated.
I'm really excited about this week's developments. It looks like we've got two things that I'm particularly interested in:
I'm thrilled to see that the system.any bug that I reported has been fixed. Thank you so much for taking care of that!
The "object construction shorthand" feature sounds incredibly promising. I know I will use it as soon as its avalible. I think it will really complemente the default values we have going on as well.
One big question though, when can we expect the full release of Nim 2.0?
When some critical regressions and showstopper issues are fixed.