Skip to content

Conversation

@timotheecour
Copy link
Member

@timotheecour timotheecour commented Apr 19, 2021

followup #17745, #9766

type A = object
  x: int

when defined case1:
  type A2 = A
  var b: A
  let c = b.x2

when defined case2:
  let a = A(x: 1, y: 2)

when defined case3:
  var a: A
  a.x2 = 3

before PR:

case1: t12184.nim(28, 12) Error: undeclared field: 'x2' for type t12184.A [type declared in t12184.nim(22, 6)]
case2: t12184.nim(31, 20) Error: undeclared field: 'y'
case3: t12184.nim(35, 8) Error: attempting to call undeclared routine: 'x2='

after PR:

case1: t12184.nim(28, 12) Error: undeclared field: 'x2' for type t12184.A [type declared in t12184.nim(22, 6)]
case2: t12184.nim(31, 20) Error: undeclared field: 'y' for type t12184.A [type declared in t12184.nim(22, 6)]
case3: t12184.nim(35, 8) Error: undeclared field: 'x2' for type t12184.A [type declared in t12184.nim(22, 6)]

(in more complex cases it may not be obvious where the underlying object is declared)

future work

block:
  type Foo[T] = object
  var a: Foo[int]
  discard a.bad2 # should improve error
  a.bad2 = 0 # should improve error
  let a2 = Foo[int](bad: 0) # should improve error

@timotheecour timotheecour marked this pull request as ready for review April 19, 2021 16:44
@juancarlospaco
Copy link
Collaborator

The work on improving the error messages is appreciated.

@timotheecour timotheecour added the Ready For Review (please take another look): ready for next review round label Apr 23, 2021
@ringabout
Copy link
Member

ringabout commented Apr 26, 2021

where is the test?

@timotheecour timotheecour force-pushed the pr_field_object_error branch from 57ad12d to 300a6b4 Compare April 26, 2021 17:43
@timotheecour timotheecour removed the Ready For Review (please take another look): ready for next review round label Apr 26, 2021
@timotheecour timotheecour force-pushed the pr_field_object_error branch from 300a6b4 to 751c5c5 Compare April 26, 2021 19:51
@timotheecour
Copy link
Member Author

where is the test?

done, PTAL

@timotheecour timotheecour added Ready For Review (please take another look): ready for next review round TODO: followup needed remove tag once fixed or tracked elsewhere labels Apr 26, 2021
@timotheecour timotheecour requested a review from ringabout April 28, 2021 03:09
@timotheecour timotheecour requested a review from Araq May 11, 2021 01:20
@timotheecour
Copy link
Member Author

timotheecour commented May 12, 2021

ping @xflywind or @Araq

@timotheecour timotheecour merged commit 3619a5a into nim-lang:devel May 16, 2021
@timotheecour timotheecour deleted the pr_field_object_error branch May 16, 2021 17:03
timotheecour added a commit to timotheecour/Nim that referenced this pull request Jun 14, 2021
timotheecour added a commit to timotheecour/Nim that referenced this pull request Jun 14, 2021
@timotheecour timotheecour removed the TODO: followup needed remove tag once fixed or tracked elsewhere label Jun 14, 2021
timotheecour added a commit to timotheecour/Nim that referenced this pull request Jun 14, 2021
Araq pushed a commit that referenced this pull request Jun 14, 2021
…18259)

* followup #17777: declaredloc field error msgs now work with generics

* fix tests

* cleanup
PMunch pushed a commit to PMunch/Nim that referenced this pull request Mar 28, 2022
PMunch pushed a commit to PMunch/Nim that referenced this pull request Mar 28, 2022
…enerics (nim-lang#18259)

* followup nim-lang#17777: declaredloc field error msgs now work with generics

* fix tests

* cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready For Review (please take another look): ready for next review round

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants