fixes #22419; async/closure environment does not align local variables (#22425)

* fixes #22419; async/closure environment does not align local variables

* Apply suggestions from code review

* Update tests/align/talign.nim

Co-authored-by: Jacek Sieka <arnetheduck@gmail.com>

* apply code review

* update tests

---------

Co-authored-by: Jacek Sieka <arnetheduck@gmail.com>
This commit is contained in:
ringabout
2023-08-09 18:43:17 +08:00
committed by GitHub
parent 989da75b84
commit 5334dc921f
2 changed files with 19 additions and 0 deletions

View File

@@ -237,6 +237,9 @@ proc addField*(obj: PType; s: PSym; cache: IdentCache; idgen: IdGenerator): PSym
field.itemId = ItemId(module: s.itemId.module, item: -s.itemId.item)
let t = skipIntLit(s.typ, idgen)
field.typ = t
if s.kind in {skLet, skVar, skField, skForVar}:
#field.bitsize = s.bitsize
field.alignment = s.alignment
assert t.kind != tyTyped
propagateToOwner(obj, t)
field.position = obj.n.len

View File

@@ -51,3 +51,19 @@ type Bug[T] = object
var bug: Bug[int]
doAssert sizeof(bug) == 128, "Oops my size is " & $sizeof(bug) # 16
block: # bug #22419
type
ValidatorPubKey = object
blob: array[96, byte]
proc f(): auto =
return iterator() =
var pad: int8 = 0
var y {.align: 16.}: ValidatorPubKey
let value = cast[uint64](addr y)
doAssert value mod 16 == 0
f()()