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

regression(1.2 => 1.4 onwards): Block-local ref types with the same name lead to bad codegen: no member named #15526

Closed
timotheecour opened this issue Oct 8, 2020 · 4 comments · Fixed by #17710

Comments

@timotheecour
Copy link
Member

timotheecour commented Oct 8, 2020

basically same as fixed #5170 but for ref types

Example

when true: # D20201008T141857
  block:
    type Foo = ref object
      x1: int
    let f1 = Foo(x1: 1)
  block:
    type Foo = ref object
      x2: int
    let f2 = Foo(x2: 2)

Current Output

@mt11116.nim.c:422:10: error: no member named 'x2' in 'struct tyObject_FoocolonObjectType___ktEbVfDBqcSUCx9b6syN8LA'
                (*T4_).x2 = ((NI) 2);

Expected Output

works

Additional Information

basically same as fixed #5170 (which was fixed) but for ref types

@timotheecour timotheecour changed the title Block-local ref types with the same name lead to bad codegen Block-local ref types with the same name lead to bad codegen: no member named Oct 8, 2020
@timotheecour
Copy link
Member Author

further info: it's a regression, it used to work in 1.2.0 (through 1.2.8)

with ref object

works in vm, js
fails in RT

when true:
  # D20201008T141857
  template fn() =
    block:
      type Foo = ref object
        x1: int
      let f1 = Foo(x1: 1)
      echo f1.x1
    block:
      type Foo = ref object
        x2: int
      let f2 = Foo(x2: 2)
      echo f2.x2
  static: fn()
  fn()

with object

works in vm, js, RT

when defined case5:
  template fn() =
    block:
      type Foo = object
        x1: int
      let f1 = Foo(x1: 1)
      echo f1.x1
    block:
      type Foo = object
        x2: int
      let f2 = Foo(x2: 2)
      echo f2.x2
  static: fn()
  fn()

@timotheecour timotheecour changed the title Block-local ref types with the same name lead to bad codegen: no member named regression(1.2 => 1.4 onwards): Block-local ref types with the same name lead to bad codegen: no member named Feb 24, 2021
@timotheecour
Copy link
Member Author

git bisect shows it's caused by 2629d61 #15091; so this is in fact the same root cause as #17162 (we could close 1 of them as duplicate, or better yet, fix the regression)

@ringabout
Copy link
Member

ringabout commented Apr 7, 2021

@timotheecour
not sure whether it is a regression, please double check the first example on Nim playground.

@timotheecour
Copy link
Member Author

timotheecour commented Apr 13, 2021

@xflywind indeed, #15526 (comment) was a regression but top example is not a regression, so there's a partial regression here; in any case i'm fixing all these here: #17710

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