Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system.create doesn't work with bitfield objects #20516

Closed
exelotl opened this issue Oct 8, 2022 · 2 comments · Fixed by #20518
Closed

system.create doesn't work with bitfield objects #20516

exelotl opened this issue Oct 8, 2022 · 2 comments · Fixed by #20518

Comments

@exelotl
Copy link
Contributor

exelotl commented Oct 8, 2022

What happened?

in Nim 1.7.x you can no longer use system.create to allocate an object that uses the bitsize pragma.

Example

type Foo = object
  x {.bitsize:4.}: uint
  y {.bitsize:4.}: uint

let a = create(Foo)

Current Output

main.nim(5, 15) template/generic instantiation of `create` from here
system/memalloc.nim(148, 18) Error: 'sizeof' requires '.importc' types to be '.completeStruct'

Additional Information

This works fine in Nim 1.6 and older.

The error is related to #19040 , but only recently has it started triggering for system.create. I don't understand why the compiler would be trying to evaluate sizeof at compile time in this scenario, if it wasn't doing so before.

Nim Version

Nim Compiler Version 1.7.3 [Linux: amd64]
Compiled at 2022-10-07
Copyright (c) 2006-2022 by Andreas Rumpf

git hash: 0d23419e681c4ce561ec43dc4a66a0ed40b8009e
active boot switches: -d:release
@ringabout
Copy link
Member

related 2bda4a3

@Araq
Copy link
Member

Araq commented Oct 8, 2022

No need to do anything but what we do in 1.6.

ringabout added a commit that referenced this issue Oct 8, 2022
Araq pushed a commit that referenced this issue Oct 8, 2022
* Revert "fixes #19000 (#19032)"

This reverts commit 2bda4a3.

* fixes #20516; add testcase
capocasa pushed a commit to capocasa/Nim that referenced this issue Mar 31, 2023
narimiran pushed a commit that referenced this issue Aug 11, 2023
* Revert "fixes #19000 (#19032)"

This reverts commit 2bda4a3.

* fixes #20516; add testcase

(cherry picked from commit 5e4dd57)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants