Skip to content

Commit 79474b5

Browse files
znzclaude
andcommitted
トップレベルの特異メソッドからのクラス変数アクセスの例外を実挙動に修正
トップレベルで定義した特異メソッド(Foo.a2)や class << Foo からのクラス 変数アクセスは NameError ではなく RuntimeError: class variable access from toplevel になる。この挙動は Ruby 3.0 で導入されたもの(Bug #14541、 NEWS-3.0.0.md 「Additionally, accessing a class variable from the toplevel scope is now a RuntimeError.」)で、るりまの対象範囲(3.0〜4.1) 全体で変わらないため無条件に修正した。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 684a58d commit 79474b5

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

manual/doc/spec/variables.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ p Foo.a1 #=> :a
185185
def Foo.a2
186186
p @@a
187187
end
188-
Foo.a2 #=> NameError になります。
188+
Foo.a2 # ~> RuntimeError: class variable access from toplevel
189189

190190
class << Foo
191-
p @@a #=> NameError になります。
191+
p @@a # ~> RuntimeError: class variable access from toplevel
192192
end
193193
```
194194

0 commit comments

Comments
 (0)