From: "schneems (Richard Schneeman)" Date: 2021-09-15T14:18:59+00:00 Subject: [ruby-core:105267] [Ruby master Feature#10982] Clarify location of NoMethod error Issue #10982 has been updated by schneems (Richard Schneeman). We can close this due to addition of error_highlight in ruby https://github.com/ruby/ruby/tree/db51bcada408f8b0b93a11d41f8e4222436bd9f2/lib/error_highlight ---------------------------------------- Feature #10982: Clarify location of NoMethod error https://bugs.ruby-lang.org/issues/10982#change-93677 * Author: schneems (Richard Schneeman) * Status: Open * Priority: Normal ---------------------------------------- In Ruby, the error `NoMethodError` on happens frequently, especially when it occurs on `nil`. This error can be confusing to beginners since, many of them think there is a problem with the method instead of the receiver. This error can be confusing to advanced developers when there are multiple method calls in the on the same line. In this example it is unclear if `foo` or `bar` returned `nil`: ``` foo.call && bar.call NoMethodError: undefined method `call' for nil:NilClass ``` I would like to make this a better error message and to indicate where the exception occurs. ``` @foo.call && @bar.call ^---- NoMethodError: The method `call` is undefined on receiver nil:NilClass ``` Now it is more clear that the `@bar` is currently `nil` and that is the source of the error. I believe exposing this information will help developers of all abilities. -- https://bugs.ruby-lang.org/ Unsubscribe: