add default field support for object in ARC/ORC (#20480)

* fresh start

* add cpp target

* add result support

* add nimPreviewRangeDefault

* reduce

* use orc

* refactor common parts

* add tuple support

* add testcase for tuple

* cleanup; fixes nimsuggest tests

* there is something wrong with cpp

* remove

* add support for seqs

* fixes style

* addd initial distinct support

* remove links

* typo

* fixes tuple defaults

* add rangedefault

* add cpp support

* fixes one more bugs

* add more hasDefaults

* fixes ordinal types

* add testcase for #16744

* add testcase for #3608

* fixes docgen

* small fix

* recursive

* fixes

* cleanup and remove tuple support

* fixes nimsuggest

* fixes generics procs

* refactor

* increases timeout

* refactor hasDefault

* zero default; disable i386

* add tuples back

* fixes bugs

* fixes tuple

* add more tests

* fix one more bug regarding tuples

* more tests and cleanup

* remove messy distinct types which must be initialized by original types

* add tests

* fixes zero default

* fixes grammar

* fixes tests

* fixes tests

* fixes tests

* fixes comments

* fixes and add testcase

* undo default values for results

Co-authored-by: flywind <43030857+xflywind@users.noreply.github.com>
This commit is contained in:
ringabout 2022-10-04 18:45:10 +08:00 • committed by GitHub
commit f89ba2c951
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 727 additions and 80 deletions

View file

@ -612,6 +612,11 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
var typFlags: TTypeAllowedFlags
var def: PNode = c.graph.emptyNode
if a[^1].kind == nkEmpty and symkind == skVar and a[^2].typ != nil:
let field = defaultNodeField(c, a[^2])
if field != nil:
a[^1] = field
field.flags.incl nfUseDefaultField
if a[^1].kind != nkEmpty:
def = semExprWithType(c, a[^1], {}, typ)
@ -680,6 +685,12 @@ proc semVarOrLet(c: PContext, n: PNode, symkind: TSymKind): PNode =
addToVarSection(c, result, n, a)
continue
var v = semIdentDef(c, a[j], symkind, false)
if a[^1].kind != nkEmpty:
if {sfThread, sfNoInit} * v.flags != {} and
nfUseDefaultField in a[^1].flags:
a[^1] = c.graph.emptyNode
def = c.graph.emptyNode
a[^1].flags.excl nfUseDefaultField
styleCheckDef(c, v)
onDef(a[j].info, v)
if sfGenSym notin v.flags: