rbs 0.19.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -0
  3. data/Rakefile +12 -0
  4. data/Steepfile +2 -1
  5. data/bin/annotate-with-rdoc +0 -4
  6. data/core/builtin.rbs +4 -0
  7. data/core/file.rbs +3 -0
  8. data/core/hash.rbs +1 -3
  9. data/core/io.rbs +165 -7
  10. data/core/kernel.rbs +1 -1
  11. data/core/module.rbs +41 -0
  12. data/core/time.rbs +0 -12
  13. data/docs/syntax.md +0 -17
  14. data/goodcheck.yml +22 -2
  15. data/lib/rbs.rb +2 -0
  16. data/lib/rbs/ast/declarations.rb +7 -49
  17. data/lib/rbs/ast/members.rb +10 -4
  18. data/lib/rbs/cli.rb +10 -10
  19. data/lib/rbs/definition.rb +70 -3
  20. data/lib/rbs/definition_builder.rb +573 -984
  21. data/lib/rbs/definition_builder/ancestor_builder.rb +525 -0
  22. data/lib/rbs/definition_builder/method_builder.rb +217 -0
  23. data/lib/rbs/environment.rb +6 -8
  24. data/lib/rbs/environment_loader.rb +8 -4
  25. data/lib/rbs/errors.rb +88 -121
  26. data/lib/rbs/method_type.rb +1 -31
  27. data/lib/rbs/parser.rb +1082 -1014
  28. data/lib/rbs/parser.y +108 -76
  29. data/lib/rbs/prototype/rb.rb +18 -3
  30. data/lib/rbs/prototype/rbi.rb +6 -6
  31. data/lib/rbs/prototype/runtime.rb +71 -35
  32. data/lib/rbs/substitution.rb +4 -0
  33. data/lib/rbs/test.rb +3 -1
  34. data/lib/rbs/test/hook.rb +26 -8
  35. data/lib/rbs/types.rb +68 -7
  36. data/lib/rbs/validator.rb +4 -2
  37. data/lib/rbs/variance_calculator.rb +5 -1
  38. data/lib/rbs/version.rb +1 -1
  39. data/lib/rbs/writer.rb +13 -4
  40. data/schema/members.json +5 -1
  41. data/sig/ancestor_builder.rbs +98 -0
  42. data/sig/declarations.rbs +4 -16
  43. data/sig/definition.rbs +6 -1
  44. data/sig/definition_builder.rbs +15 -67
  45. data/sig/errors.rbs +159 -0
  46. data/sig/members.rbs +4 -1
  47. data/sig/method_builder.rbs +71 -0
  48. data/sig/method_types.rbs +3 -16
  49. data/sig/substitution.rbs +3 -0
  50. data/sig/type_name_resolver.rbs +4 -2
  51. data/sig/types.rbs +17 -15
  52. data/sig/validator.rbs +12 -0
  53. data/stdlib/csv/0/csv.rbs +3 -0
  54. data/stdlib/dbm/0/dbm.rbs +0 -2
  55. data/stdlib/logger/0/log_device.rbs +1 -2
  56. data/stdlib/pathname/0/pathname.rbs +1 -1
  57. data/stdlib/prime/0/prime.rbs +6 -0
  58. data/stdlib/securerandom/0/securerandom.rbs +2 -0
  59. data/stdlib/time/0/time.rbs +327 -0
  60. data/stdlib/tsort/0/tsort.rbs +8 -0
  61. data/stdlib/uri/0/common.rbs +401 -0
  62. data/stdlib/uri/0/rfc2396_parser.rbs +9 -0
  63. data/stdlib/uri/0/rfc3986_parser.rbs +2 -0
  64. data/steep/Gemfile.lock +13 -14
  65. metadata +12 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8305afa064e98cd22b78a49fb402692abed204c735a7ce05d90f6a48d7bd6b96
4
- data.tar.gz: 7840d67b2bbd54eb041342e093892b6d1046b21b6655b80eba109df6b773451d
3
+ metadata.gz: be247bc7ef91a934ace7a51d77b2c9070a0b8928427221e60bc848cb3158ebaf
4
+ data.tar.gz: becf4b84e220f43ead96eb742cbf8cbbfec0e0fc5dce3c6837c2a5ff3a95467a
5
5
  SHA512:
6
- metadata.gz: 4919d1fd1323fa5cb2c40f89f5338d2168d3ae4fcabed2e2c428b3e5b4bacda2e395e9dfb2fc52a6517e75137358118b4142b330f607f77c162f259485ac0b13
7
- data.tar.gz: dc36b905d8c746eb5e976f6f3fc4a06ba8ed2b037d15d73e8bfa4360497c9c814f44dd604981f7c3622002ef0bb603b1b9374e2f49ab0af67bc35ecbe2d7b26e
6
+ metadata.gz: 2c200273bbcf2e454082377a0e5e1c9b4fba0f9328c44e026b0eba2a7c3175d98b2cd11b5c8267792e54e207581aea9a46cd30472a3aec640ae7aff89e9e8ebe
7
+ data.tar.gz: 67038167fef41256ed56262aa4b1df3a6099c82687498c7921cd869a79c927c86abd19134bd228c78abda04aed9af3b4b3ccbac38548d74c6cfba650965380d0
@@ -2,6 +2,33 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.0.0 (2020-12-24)
6
+
7
+ * Signature updates for `URI`, `IO`, `File`, `Pathname`, `Module`, and `Time` ([#529](https://github.com/ruby/rbs/pull/529), [#521](https://github.com/ruby/rbs/pull/521), [#520](https://github.com/ruby/rbs/pull/520), [#511](https://github.com/ruby/rbs/pull/511), [#517](https://github.com/ruby/rbs/pull/517), [#542](https://github.com/ruby/rbs/pull/542), [#546](https://github.com/ruby/rbs/pull/546), [#540](https://github.com/ruby/rbs/pull/540), [#538](https://github.com/ruby/rbs/pull/538))
8
+ * `rbs prototype runtime` generates `extend`s ([#535](https://github.com/ruby/rbs/pull/535))
9
+ * `rbs prototype runtime` stability improvements ([#533](https://github.com/ruby/rbs/pull/533), [#526](https://github.com/ruby/rbs/pull/526))
10
+ * `rbs prototype rb` compatibility improvements ([#545](https://github.com/ruby/rbs/pull/545))
11
+ * Implement method names escape in `RBS::Writer` ([#537](https://github.com/ruby/rbs/pull/537))
12
+ * Improve runtime type checker compatibility ([#532](https://github.com/ruby/rbs/pull/532), [#528](https://github.com/ruby/rbs/pull/528), [#547](https://github.com/ruby/rbs/pull/547))
13
+ * Fix `ruby2_keywords` for `Proc` in Ruby <2.7 ([#513](https://github.com/ruby/rbs/pull/513))
14
+ * Better compatibility for record type attribute names ([#525](https://github.com/ruby/rbs/pull/525), [#524](https://github.com/ruby/rbs/pull/524))
15
+ * Let module self-types be classes ([#523](https://github.com/ruby/rbs/pull/523))
16
+ * Delete `extension` syntax ([#543](https://github.com/ruby/rbs/pull/543))
17
+ * Method resolution improvements about `alias` and `.new` ([#522](https://github.com/ruby/rbs/pull/522), [#519](https://github.com/ruby/rbs/pull/519), [#516](https://github.com/ruby/rbs/pull/516))
18
+ * Better message for `DuplicatedMethodDefinitionError` ([#539](https://github.com/ruby/rbs/pull/539))
19
+
20
+ ## 0.20.1 (2020-12-06)
21
+
22
+ * Make the order of RBS load reproducible ([#508](https://github.com/ruby/rbs/pull/508))
23
+
24
+ ## 0.20.0 (2020-12-06)
25
+
26
+ * Signature updates for `TSort`, `DBM`, `Time`, and `Hash` ([#496](https://github.com/ruby/rbs/pull/496), [#497](https://github.com/ruby/rbs/pull/497), [#499](https://github.com/ruby/rbs/pull/499), [#507](https://github.com/ruby/rbs/pull/507))
27
+ * Add _singleton attribute_ syntax ([#502](https://github.com/ruby/rbs/pull/502), [#506](https://github.com/ruby/rbs/pull/506), [#505](https://github.com/ruby/rbs/pull/505))
28
+ * Proc types with blocks ([#503](https://github.com/ruby/rbs/pull/503))
29
+ * Add support for escape sequences in string literal types ([#501](https://github.com/ruby/rbs/pull/501))
30
+ * Fix runtime type checking of blocks with keyword args ([#500](https://github.com/ruby/rbs/pull/500))
31
+
5
32
  ## 0.19.0 (2020-12-02)
6
33
 
7
34
  * Signature updates for `Monitor` and File ([#485](https://github.com/ruby/rbs/pull/485), [#495](https://github.com/ruby/rbs/pull/495))
data/Rakefile CHANGED
@@ -41,6 +41,18 @@ task :validate => :parser do
41
41
  lib << "pstore"
42
42
  end
43
43
 
44
+ if lib == ["logger"]
45
+ lib << "monitor"
46
+ end
47
+
48
+ if lib == ["csv"]
49
+ lib << "forwardable"
50
+ end
51
+
52
+ if lib == ["prime"]
53
+ lib << "singleton"
54
+ end
55
+
44
56
  sh "#{ruby} #{rbs} #{lib.map {|l| "-r #{l}"}.join(" ")} validate --silent"
45
57
  end
46
58
  end
data/Steepfile CHANGED
@@ -2,8 +2,9 @@ target :lib do
2
2
  signature "sig"
3
3
  check "lib"
4
4
  ignore "lib/rbs/parser.rb"
5
+ ignore "lib/rbs/prototype", "lib/rbs/test", "lib/rbs/test.rb"
5
6
 
6
- library "set", "pathname", "json", "logger"
7
+ library "set", "pathname", "json", "logger", "monitor", "tsort"
7
8
  end
8
9
 
9
10
  # target :lib do
@@ -140,10 +140,6 @@ ARGV.map {|f| Pathname(f) }.each do |path|
140
140
  comment = comment_for_class(decl, stores: stores)
141
141
  decl.instance_variable_set(:@comment, comment)
142
142
 
143
- print_members stores, decl.name.to_s, decl.members
144
- when RBS::AST::Declarations::Extension
145
- puts " Importing documentation for #{decl.name} (#{decl.extension_name})"
146
-
147
143
  print_members stores, decl.name.to_s, decl.members
148
144
  end
149
145
  end
@@ -34,6 +34,10 @@ interface _Reader
34
34
  def read: (?int length, ?string outbuf) -> String?
35
35
  end
36
36
 
37
+ interface _ReaderPartial
38
+ def readpartial: (int maxlen, ?string outbuf) -> String
39
+ end
40
+
37
41
  interface _Writer
38
42
  # Writes the +data+ string. Returns the number of bytes written
39
43
  def write: (*_ToS data) -> Integer
@@ -531,6 +531,9 @@ class File < IO
531
531
  #
532
532
  def self.mtime: (string | _ToPath | IO file_name) -> Time
533
533
 
534
+ # Alias of `File.new`.
535
+ def self.open: (string | _ToPath | int file_name, ?(string | int) mode, ?int perm) -> instance
536
+
534
537
  # Returns `true` if the named file exists and the effective used id of the
535
538
  # calling process is the owner of the file.
536
539
  #
@@ -563,8 +563,6 @@ class Hash[unchecked out K, unchecked out V] < Object
563
563
  #
564
564
  alias include? has_key?
565
565
 
566
- def index: (V) -> K?
567
-
568
566
  # Return the contents of this hash as a string.
569
567
  #
570
568
  # h = { "c" => 300, "a" => 100, "d" => 400, "c" => 300 }
@@ -615,7 +613,7 @@ class Hash[unchecked out K, unchecked out V] < Object
615
613
  # h.key(300) #=> "c"
616
614
  # h.key(999) #=> nil
617
615
  #
618
- alias key index
616
+ def key: (V) -> K?
619
617
 
620
618
  # Returns `true` if the given key is present in *hsh*.
621
619
  #
@@ -405,7 +405,63 @@ class IO < Object
405
405
 
406
406
  def puts: (*untyped arg0) -> NilClass
407
407
 
408
- def read: (?Integer length, ?String outbuf) -> String?
408
+ # Reads *length* bytes from the I/O stream.
409
+ #
410
+ # *length* must be a non-negative integer or `nil`.
411
+ #
412
+ # If *length* is a positive integer, `read` tries to read *length* bytes without
413
+ # any conversion (binary mode). It returns `nil` if an EOF is encountered before
414
+ # anything can be read. Fewer than *length* bytes are returned if an EOF is
415
+ # encountered during the read. In the case of an integer *length*, the resulting
416
+ # string is always in ASCII-8BIT encoding.
417
+ #
418
+ # If *length* is omitted or is `nil`, it reads until EOF and the encoding
419
+ # conversion is applied, if applicable. A string is returned even if EOF is
420
+ # encountered before any data is read.
421
+ #
422
+ # If *length* is zero, it returns an empty string (`""`).
423
+ #
424
+ # If the optional *outbuf* argument is present, it must reference a String,
425
+ # which will receive the data. The *outbuf* will contain only the received data
426
+ # after the method call even if it is not empty at the beginning.
427
+ #
428
+ # When this method is called at end of file, it returns `nil` or `""`, depending
429
+ # on *length*: `read`, `read(nil)`, and `read(0)` return `""`,
430
+ # `read(*positive_integer*)` returns `nil`.
431
+ #
432
+ # f = File.new("testfile")
433
+ # f.read(16) #=> "This is line one"
434
+ #
435
+ # # read whole file
436
+ # open("file") do |f|
437
+ # data = f.read # This returns a string even if the file is empty.
438
+ # # ...
439
+ # end
440
+ #
441
+ # # iterate over fixed length records
442
+ # open("fixed-record-file") do |f|
443
+ # while record = f.read(256)
444
+ # # ...
445
+ # end
446
+ # end
447
+ #
448
+ # # iterate over variable length records,
449
+ # # each record is prefixed by its 32-bit length
450
+ # open("variable-record-file") do |f|
451
+ # while len = f.read(4)
452
+ # len = len.unpack("N")[0] # 32-bit length
453
+ # record = f.read(len) # This returns a string even if len is 0.
454
+ # end
455
+ # end
456
+ #
457
+ # Note that this method behaves like the fread() function in C. This means it
458
+ # retries to invoke read(2) system calls to read data with the specified length
459
+ # (or until EOF). This behavior is preserved even if *ios* is in non-blocking
460
+ # mode. (This method is non-blocking flag insensitive as other methods.) If you
461
+ # need the behavior like a single read(2) system call, consider #readpartial,
462
+ # #read_nonblock, and #sysread.
463
+ #
464
+ def read: (?Integer? length, ?String outbuf) -> String?
409
465
 
410
466
  def read_nonblock: (Integer len) -> String
411
467
  | (Integer len, ?String buf) -> String
@@ -428,8 +484,63 @@ class IO < Object
428
484
 
429
485
  def readlines: (?String sep, ?Integer limit) -> ::Array[String]
430
486
 
431
- def readpartial: (Integer maxlen) -> String
432
- | (Integer maxlen, ?String outbuf) -> String
487
+ # Reads at most *maxlen* bytes from the I/O stream. It blocks only if *ios* has
488
+ # no data immediately available. It doesn't block if some data available.
489
+ #
490
+ # If the optional *outbuf* argument is present, it must reference a String,
491
+ # which will receive the data. The *outbuf* will contain only the received data
492
+ # after the method call even if it is not empty at the beginning.
493
+ #
494
+ # It raises EOFError on end of file.
495
+ #
496
+ # readpartial is designed for streams such as pipe, socket, tty, etc. It blocks
497
+ # only when no data immediately available. This means that it blocks only when
498
+ # following all conditions hold.
499
+ # * the byte buffer in the IO object is empty.
500
+ # * the content of the stream is empty.
501
+ # * the stream is not reached to EOF.
502
+ #
503
+ #
504
+ # When readpartial blocks, it waits data or EOF on the stream. If some data is
505
+ # reached, readpartial returns with the data. If EOF is reached, readpartial
506
+ # raises EOFError.
507
+ #
508
+ # When readpartial doesn't blocks, it returns or raises immediately. If the byte
509
+ # buffer is not empty, it returns the data in the buffer. Otherwise if the
510
+ # stream has some content, it returns the data in the stream. Otherwise if the
511
+ # stream is reached to EOF, it raises EOFError.
512
+ #
513
+ # r, w = IO.pipe # buffer pipe content
514
+ # w << "abc" # "" "abc".
515
+ # r.readpartial(4096) #=> "abc" "" ""
516
+ # r.readpartial(4096) # blocks because buffer and pipe is empty.
517
+ #
518
+ # r, w = IO.pipe # buffer pipe content
519
+ # w << "abc" # "" "abc"
520
+ # w.close # "" "abc" EOF
521
+ # r.readpartial(4096) #=> "abc" "" EOF
522
+ # r.readpartial(4096) # raises EOFError
523
+ #
524
+ # r, w = IO.pipe # buffer pipe content
525
+ # w << "abc\ndef\n" # "" "abc\ndef\n"
526
+ # r.gets #=> "abc\n" "def\n" ""
527
+ # w << "ghi\n" # "def\n" "ghi\n"
528
+ # r.readpartial(4096) #=> "def\n" "" "ghi\n"
529
+ # r.readpartial(4096) #=> "ghi\n" "" ""
530
+ #
531
+ # Note that readpartial behaves similar to sysread. The differences are:
532
+ # * If the byte buffer is not empty, read from the byte buffer instead of
533
+ # "sysread for buffered IO (IOError)".
534
+ # * It doesn't cause Errno::EWOULDBLOCK and Errno::EINTR. When readpartial
535
+ # meets EWOULDBLOCK and EINTR by read system call, readpartial retry the
536
+ # system call.
537
+ #
538
+ #
539
+ # The latter means that readpartial is nonblocking-flag insensitive. It blocks
540
+ # on the situation IO#sysread causes Errno::EWOULDBLOCK as if the fd is blocking
541
+ # mode.
542
+ #
543
+ def readpartial: (Integer maxlen, ?String outbuf) -> String
433
544
 
434
545
  def reopen: (IO other_IO_or_path) -> IO
435
546
  | (String other_IO_or_path, ?String mode_str) -> IO
@@ -508,13 +619,55 @@ class IO < Object
508
619
 
509
620
  def ungetc: (String arg0) -> NilClass
510
621
 
511
- def write: (*_ToS arg0) -> Integer
622
+ # Writes the given strings to *ios*. The stream must be opened for writing.
623
+ # Arguments that are not a string will be converted to a string using `to_s`.
624
+ # Returns the number of bytes written in total.
625
+ #
626
+ # count = $stdout.write("This is", " a test\n")
627
+ # puts "That was #{count} bytes of data"
628
+ #
629
+ # *produces:*
630
+ #
631
+ # This is a test
632
+ # That was 15 bytes of data
633
+ #
634
+ def write: (*_ToS string) -> Integer
512
635
 
636
+ # Opens the file, optionally seeks to the given *offset*, then returns *length*
637
+ # bytes (defaulting to the rest of the file). #binread ensures the file is
638
+ # closed before returning. The open mode would be `"rb:ASCII-8BIT"`.
639
+ #
640
+ # IO.binread("testfile") #=> "This is line one\nThis is line two\nThis is line three\nAnd so on...\n"
641
+ # IO.binread("testfile", 20) #=> "This is line one\nThi"
642
+ # IO.binread("testfile", 20, 10) #=> "ne one\nThis is line "
643
+ #
513
644
  def self.binread: (String name, ?Integer length, ?Integer offset) -> String
514
645
 
515
- def self.binwrite: (String name, _ToS arg0, ?Integer offset, ?external_encoding: String external_encoding, ?internal_encoding: String internal_encoding, ?encoding: String encoding, ?textmode: untyped textmode, ?binmode: untyped binmode, ?autoclose: untyped autoclose, ?mode: String mode) -> Integer
646
+ # Same as IO.write except opening the file in binary mode and ASCII-8BIT
647
+ # encoding (`"wb:ASCII-8BIT"`).
648
+ #
649
+ def self.binwrite: (String name, _ToS string, ?Integer offset, ?mode: String mode) -> Integer
516
650
 
517
- def self.copy_stream: (_Reader src, _Writer dst, ?Integer copy_length, ?Integer src_offset) -> Integer
651
+ # IO.copy_stream copies *src* to *dst*. *src* and *dst* is either a filename or
652
+ # an IO-like object. IO-like object for *src* should have #readpartial or #read
653
+ # method. IO-like object for *dst* should have #write method. (Specialized
654
+ # mechanisms, such as sendfile system call, may be used on appropriate
655
+ # situation.)
656
+ #
657
+ # This method returns the number of bytes copied.
658
+ #
659
+ # If optional arguments are not given, the start position of the copy is the
660
+ # beginning of the filename or the current file offset of the IO. The end
661
+ # position of the copy is the end of file.
662
+ #
663
+ # If *copy_length* is given, No more than *copy_length* bytes are copied.
664
+ #
665
+ # If *src_offset* is given, it specifies the start position of the copy.
666
+ #
667
+ # When *src_offset* is specified and *src* is an IO, IO.copy_stream doesn't move
668
+ # the current file offset.
669
+ #
670
+ def self.copy_stream: ((String | _Reader | _ReaderPartial) src, (String | _Writer) dst, ?Integer copy_length, ?Integer src_offset) -> Integer
518
671
 
519
672
  def self.popen: (*untyped args) -> untyped
520
673
 
@@ -530,7 +683,12 @@ class IO < Object
530
683
 
531
684
  def self.write: (String name, _ToS arg0, ?Integer offset, ?external_encoding: String external_encoding, ?internal_encoding: String internal_encoding, ?encoding: String encoding, ?textmode: untyped textmode, ?binmode: untyped binmode, ?autoclose: untyped autoclose, ?mode: String mode) -> Integer
532
685
 
533
- def self.for_fd: (Integer fd, ?Integer mode, ?Integer opt) -> self
686
+ def self.for_fd: (int fd, ?(string | int) mode, **untyped opt) -> instance
687
+
688
+ alias self.open self.for_fd
689
+
690
+ def self.open: [A] (int fd, ?(string | int) mode, **untyped opt) { (instance) -> A } -> A
691
+ | ...
534
692
 
535
693
  def bytes: () { (Integer arg0) -> untyped } -> self
536
694
  | () -> ::Enumerator[Integer, self]
@@ -10,7 +10,7 @@
10
10
  # ```ruby
11
11
  # sprintf "%.1f", 1.234 #=> "1.2"
12
12
  # ```
13
- module Kernel
13
+ module Kernel : BasicObject
14
14
  private
15
15
 
16
16
  def caller: (?Integer start_or_range, ?Integer length) -> ::Array[String]?
@@ -443,6 +443,47 @@ class Module < Object
443
443
  #
444
444
  def const_set: (Symbol | String arg0, untyped arg1) -> untyped
445
445
 
446
+ # Returns the Ruby source filename and line number containing first definition
447
+ # of constant specified. If the named constant is not found, `nil` is returned.
448
+ # If the constant is found, but its source location can not be extracted
449
+ # (constant is defined in C code), empty array is returned.
450
+ #
451
+ # *inherit* specifies whether to lookup in `mod.ancestors` (`true` by default).
452
+ #
453
+ # # test.rb:
454
+ # class A
455
+ # C1 = 1
456
+ # end
457
+ #
458
+ # module M
459
+ # C2 = 2
460
+ # end
461
+ #
462
+ # class B < A
463
+ # include M
464
+ # C3 = 3
465
+ # end
466
+ #
467
+ # class A # continuation of A definition
468
+ # end
469
+ #
470
+ # p B.const_source_location('C3') # => ["test.rb", 11]
471
+ # p B.const_source_location('C2') # => ["test.rb", 6]
472
+ # p B.const_source_location('C1') # => ["test.rb", 2]
473
+ #
474
+ # p B.const_source_location('C2', false) # => nil -- don't lookup in ancestors
475
+ #
476
+ # p Object.const_source_location('B') # => ["test.rb", 9]
477
+ # p Object.const_source_location('A') # => ["test.rb", 1] -- note it is first entry, not "continuation"
478
+ #
479
+ # p B.const_source_location('A') # => ["test.rb", 1] -- because Object is in ancestors
480
+ # p M.const_source_location('A') # => ["test.rb", 1] -- Object is not ancestor, but additionally checked for modules
481
+ #
482
+ # p Object.const_source_location('A::C1') # => ["test.rb", 2] -- nesting is supported
483
+ # p Object.const_source_location('String') # => [] -- constant is defined in C code
484
+ #
485
+ def const_source_location: (Symbol | String name, ?boolish inherit) -> ([String, Integer] | [ ] | nil)
486
+
446
487
  # Returns an array of the names of the constants accessible in *mod*. This
447
488
  # includes the names of constants in any included modules (example at start of
448
489
  # section), unless the *inherit* parameter is set to `false`.
@@ -757,18 +757,6 @@ class Time < Object
757
757
  #
758
758
  def subsec: () -> Numeric
759
759
 
760
- # Returns a new Time object, one second later than *time*. Time#succ is obsolete
761
- # since 1.9.2 for time is not a discrete value.
762
- #
763
- # t = Time.now #=> 2007-11-19 08:23:57 -0600
764
- # t.succ #=> 2007-11-19 08:23:58 -0600
765
- #
766
- # Use instead `time + 1`
767
- #
768
- # t + 1 #=> 2007-11-19 08:23:58 -0600
769
- #
770
- def succ: () -> Time
771
-
772
760
  # Returns `true` if *time* represents Sunday.
773
761
  #
774
762
  # t = Time.local(1990, 4, 1) #=> 1990-04-01 00:00:00 -0600
@@ -531,23 +531,6 @@ interface _Foo
531
531
  end
532
532
  ```
533
533
 
534
- ### Extension declaration
535
-
536
- Extension is to model _open class_.
537
-
538
- ```
539
- extension Kernel (Pathname)
540
- def Pathname: (String) -> Pathname
541
- end
542
-
543
- extension Array[A] (ActiveSupport)
544
- def to: (Integer) -> Array[A]
545
- def from: (Integer) -> Array[A]
546
- def second: () -> A?
547
- def third: () -> A?
548
- end
549
- ```
550
-
551
534
  ### Type alias declaration
552
535
 
553
536
  You can declare an alias of types.
@@ -3,7 +3,7 @@ rules:
3
3
  pattern: 💪👽🚨
4
4
  message: Do you forget to delete `arglists` section?
5
5
  glob:
6
- - "stdlib/**/*.rbs"
6
+ - "{core,stdlib}/**/*.rbs"
7
7
  fail:
8
8
  - |
9
9
  # arglists 💪👽🚨 << Delete this section
@@ -22,12 +22,32 @@ rules:
22
22
  justification:
23
23
  - Documents (comments) may contain that pattern.
24
24
  glob:
25
- - "stdlib/**/*.rbs"
25
+ - "{core,stdlib}/**/*.rbs"
26
26
  fail:
27
27
  - "def `send`: (String | Symbol arg0, *untyped arg1) -> untyped"
28
28
  pass:
29
29
  - "def `send`: (String | Symbol, *untyped) -> untyped"
30
30
 
31
+ - id: rbs.prefer_boolish
32
+ pattern:
33
+ - regexp: '\([^(]*\bbool\b[^\n]*\)'
34
+ - token: "-> bool }"
35
+ message: |
36
+ Prefer `boolish` over `bool` for method arguments and block return values
37
+
38
+ See the doc below:
39
+ https://github.com/ruby/rbs/blob/78d04a2db0f1c4925d2b13c2939868edf9465d6c/docs/syntax.md#bool-or-boolish
40
+ glob:
41
+ - "**/*.rbs"
42
+ justification:
43
+ - When you strictly want `true | false`.
44
+ pass:
45
+ - "(arg: boolish)"
46
+ - "{ () -> boolish }"
47
+ fail:
48
+ - "(arg: bool)"
49
+ - "{ () -> bool }"
50
+
31
51
  - id: deprecate_stdlib_test
32
52
  pattern:
33
53
  token: < StdlibTest