Skip to content

Block-local types with the same name lead to bad codegen (sighashes regression) #5170

Closed
@nigredo-tori

Description

@nigredo-tori

Example:

block:
  type Foo = object
    bar: bool
  var f1: Foo

block:
  type Foo = object
    baz: int
  var f2: Foo
  echo f2.baz

Leads to incorrect code generation:

Error: execution of an external compiler program 'gcc -c  -w  -I/home/nigredo/dev/nim/lib -o /home/nigredo/dev/tmp/nimcache/test_block_types.o /home/nigredo/dev/tmp/nimcache/test_block_types.c' failed with exit code: 1

/home/nigredo/dev/tmp/nimcache/test_block_types.c: In function ‘NimMainModule’:
/home/nigredo/dev/tmp/nimcache/test_block_types.c:113:47: error: ‘Foo_ERzUuJDwNMfy52HTAAjijQ {aka struct Foo_ERzUuJDwNMfy52HTAAjijQ}’ has no member named ‘baz’; did you mean ‘bar’?
   LOC3 = nimIntToStr(f2_lLsGauUAFcJDvAdQ34YRQA.baz);
                                               ^

Tested on: bf8f00f
Bisect points to: 860cbd3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions