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

create / createShared regression : "type mismatch: got (ptr Foo) but expected 'ptr None'" #5648

Closed
singularperturbation opened this issue Apr 1, 2017 · 0 comments
Assignees

Comments

@singularperturbation
Copy link
Contributor

type Foo = object
  fooInt*: int

proc main() =
  # Error: type mismatch: got (ptr Foo) but expected 'ptr None'
  var f = create(Foo)
  f.fooInt = 3
  echo $f
  discard realloc(f, 0)

  var g = Foo()
  g.fooInt = 3
  echo $g


when isMainModule:
  main()

I think the problem is with passing a typedesc parameter in the proc rather than leaving it as a generic parameter. If I do

template workaround_create[T]: ptr T = cast[ptr T](alloc0(sizeof(T)))

then this will compile and work.

Gist of the above

@zah zah self-assigned this Apr 2, 2017
jangko added a commit to jangko/Nim that referenced this issue Apr 3, 2017
@Araq Araq closed this as completed in eb635d9 May 17, 2017
metagn added a commit to metagn/Nim that referenced this issue Aug 27, 2023
closes nim-lang#12582, closes nim-lang#19552, closes nim-lang#2465, closes nim-lang#4596, closes nim-lang#15246,
closes nim-lang#12683, closes nim-lang#7889, closes nim-lang#4547, closes nim-lang#12415, closes nim-lang#2002,
closes nim-lang#1771, closes nim-lang#5121

The test for nim-lang#5648 is also moved into its own test
from `types/tissues_types` due to not being joinable.
Araq pushed a commit that referenced this issue Aug 27, 2023
* test case haul for old generic/template/macro issues

closes #12582, closes #19552, closes #2465, closes #4596, closes #15246,
closes #12683, closes #7889, closes #4547, closes #12415, closes #2002,
closes #1771, closes #5121

The test for #5648 is also moved into its own test
from `types/tissues_types` due to not being joinable.

* fix template gensym test
narimiran pushed a commit that referenced this issue Sep 18, 2023
* test case haul for old generic/template/macro issues

closes #12582, closes #19552, closes #2465, closes #4596, closes #15246,
closes #12683, closes #7889, closes #4547, closes #12415, closes #2002,
closes #1771, closes #5121

The test for #5648 is also moved into its own test
from `types/tissues_types` due to not being joinable.

* fix template gensym test

(cherry picked from commit c19fd69)
narimiran pushed a commit that referenced this issue Sep 18, 2023
* test case haul for old generic/template/macro issues

closes #12582, closes #19552, closes #2465, closes #4596, closes #15246,
closes #12683, closes #7889, closes #4547, closes #12415, closes #2002,
closes #1771, closes #5121

The test for #5648 is also moved into its own test
from `types/tissues_types` due to not being joinable.

* fix template gensym test

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

No branches or pull requests

3 participants