rbs 1.7.0.beta.2 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +20 -1
  3. data/.gitignore +9 -2
  4. data/CHANGELOG.md +36 -9
  5. data/Rakefile +15 -0
  6. data/Steepfile +0 -1
  7. data/core/binding.rbs +2 -0
  8. data/core/complex.rbs +0 -2
  9. data/core/env.rbs +881 -0
  10. data/core/false_class.rbs +2 -0
  11. data/core/float.rbs +0 -2
  12. data/core/integer.rbs +0 -2
  13. data/core/nil_class.rbs +2 -0
  14. data/core/numeric.rbs +7 -0
  15. data/core/object.rbs +1 -1
  16. data/core/proc.rbs +2 -0
  17. data/core/rational.rbs +0 -2
  18. data/core/symbol.rbs +2 -0
  19. data/core/true_class.rbs +2 -0
  20. data/core/unbound_method.rbs +13 -0
  21. data/docs/rbs_by_example.md +2 -2
  22. data/docs/syntax.md +2 -3
  23. data/ext/rbs_extension/constants.c +0 -1
  24. data/ext/rbs_extension/lexer.c +2526 -1063
  25. data/ext/rbs_extension/lexer.h +33 -17
  26. data/ext/rbs_extension/lexer.re +140 -0
  27. data/ext/rbs_extension/lexstate.c +139 -0
  28. data/ext/rbs_extension/parser.c +2 -32
  29. data/ext/rbs_extension/parser.h +0 -5
  30. data/ext/rbs_extension/parserstate.c +0 -1
  31. data/ext/rbs_extension/rbs_extension.h +1 -1
  32. data/ext/rbs_extension/ruby_objs.c +84 -148
  33. data/ext/rbs_extension/ruby_objs.h +0 -2
  34. data/lib/rbs/collection/installer.rb +1 -0
  35. data/lib/rbs/collection/sources/git.rb +6 -1
  36. data/lib/rbs/errors.rb +6 -0
  37. data/lib/rbs/parser_aux.rb +37 -5
  38. data/lib/rbs/parser_compat/lexer_error.rb +4 -0
  39. data/lib/rbs/parser_compat/located_value.rb +5 -0
  40. data/lib/rbs/parser_compat/semantics_error.rb +4 -0
  41. data/lib/rbs/parser_compat/syntax_error.rb +4 -0
  42. data/lib/rbs/prototype/helpers.rb +113 -0
  43. data/lib/rbs/prototype/rb.rb +2 -105
  44. data/lib/rbs/prototype/runtime.rb +16 -0
  45. data/lib/rbs/test/setup.rb +1 -0
  46. data/lib/rbs/types.rb +2 -2
  47. data/lib/rbs/version.rb +1 -1
  48. data/lib/rbs.rb +12 -0
  49. data/sig/parser.rbs +2 -0
  50. data/sig/rbs.rbs +4 -0
  51. data/stdlib/bigdecimal/0/big_decimal.rbs +44 -0
  52. data/stdlib/csv/0/csv.rbs +49 -3
  53. data/stdlib/io-console/0/io-console.rbs +137 -0
  54. data/stdlib/net-http/0/net-http.rbs +2 -1
  55. data/stdlib/tempfile/0/tempfile.rbs +4 -6
  56. metadata +13 -5
  57. data/lib/rbs/parser.y +0 -1805
@@ -0,0 +1,113 @@
1
+ module RBS
2
+ module Prototype
3
+ module Helpers
4
+ private
5
+
6
+ def block_from_body(node)
7
+ _, args_node, body_node = node.children
8
+
9
+ _pre_num, _pre_init, _opt, _first_post, _post_num, _post_init, _rest, _kw, _kwrest, block = args_from_node(args_node)
10
+
11
+ method_block = nil
12
+
13
+ if block
14
+ method_block = Types::Block.new(
15
+ # HACK: The `block` is :& on `def m(...)` syntax.
16
+ # In this case the block looks optional in most cases, so it marks optional.
17
+ # In other cases, we can't determine which is required or optional, so it marks required.
18
+ required: block != :&,
19
+ type: Types::Function.empty(untyped)
20
+ )
21
+ end
22
+
23
+ if body_node
24
+ if (yields = any_node?(body_node) {|n| n.type == :YIELD })
25
+ method_block = Types::Block.new(
26
+ required: true,
27
+ type: Types::Function.empty(untyped)
28
+ )
29
+
30
+ yields.each do |yield_node|
31
+ array_content = yield_node.children[0]&.children&.compact || []
32
+
33
+ positionals, keywords = if keyword_hash?(array_content.last)
34
+ [array_content.take(array_content.size - 1), array_content.last]
35
+ else
36
+ [array_content, nil]
37
+ end
38
+
39
+ if (diff = positionals.size - method_block.type.required_positionals.size) > 0
40
+ diff.times do
41
+ method_block.type.required_positionals << Types::Function::Param.new(
42
+ type: untyped,
43
+ name: nil
44
+ )
45
+ end
46
+ end
47
+
48
+ if keywords
49
+ keywords.children[0].children.each_slice(2) do |key_node, value_node|
50
+ if key_node
51
+ key = key_node.children[0]
52
+ method_block.type.required_keywords[key] ||=
53
+ Types::Function::Param.new(
54
+ type: untyped,
55
+ name: nil
56
+ )
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ method_block
65
+ end
66
+
67
+ def each_child(node, &block)
68
+ each_node node.children, &block
69
+ end
70
+
71
+ def each_node(nodes)
72
+ nodes.each do |child|
73
+ if child.is_a?(RubyVM::AbstractSyntaxTree::Node)
74
+ yield child
75
+ end
76
+ end
77
+ end
78
+
79
+
80
+ def any_node?(node, nodes: [], &block)
81
+ if yield(node)
82
+ nodes << node
83
+ end
84
+
85
+ each_child node do |child|
86
+ any_node? child, nodes: nodes, &block
87
+ end
88
+
89
+ nodes.empty? ? nil : nodes
90
+ end
91
+
92
+ def keyword_hash?(node)
93
+ if node
94
+ if node.type == :HASH
95
+ node.children[0].children.compact.each_slice(2).all? {|key, _|
96
+ key.type == :LIT && key.children[0].is_a?(Symbol)
97
+ }
98
+ end
99
+ end
100
+ end
101
+
102
+ # NOTE: args_node may be a nil by a bug
103
+ # https://bugs.ruby-lang.org/issues/17495
104
+ def args_from_node(args_node)
105
+ args_node&.children || [0, nil, nil, nil, 0, nil, nil, nil, nil, nil]
106
+ end
107
+
108
+ def untyped
109
+ @untyped ||= Types::Bases::Any.new(location: nil)
110
+ end
111
+ end
112
+ end
113
+ end
@@ -1,6 +1,8 @@
1
1
  module RBS
2
2
  module Prototype
3
3
  class RB
4
+ include Helpers
5
+
4
6
  Context = Struct.new(:module_function, :singleton, :namespace, keyword_init: true) do
5
7
  def self.initial(namespace: Namespace.root)
6
8
  self.new(module_function: false, singleton: false, namespace: namespace)
@@ -372,18 +374,6 @@ module RBS
372
374
  end
373
375
  end
374
376
 
375
- def each_node(nodes)
376
- nodes.each do |child|
377
- if child.is_a?(RubyVM::AbstractSyntaxTree::Node)
378
- yield child
379
- end
380
- end
381
- end
382
-
383
- def each_child(node, &block)
384
- each_node node.children, &block
385
- end
386
-
387
377
  def function_type_from_body(node, def_name)
388
378
  table_node, args_node, *_ = node.children
389
379
 
@@ -568,95 +558,6 @@ module RBS
568
558
  end
569
559
  end
570
560
 
571
- def block_from_body(node)
572
- _, args_node, body_node = node.children
573
-
574
- _pre_num, _pre_init, _opt, _first_post, _post_num, _post_init, _rest, _kw, _kwrest, block = args_from_node(args_node)
575
-
576
- method_block = nil
577
-
578
- if block
579
- method_block = Types::Block.new(
580
- # HACK: The `block` is :& on `def m(...)` syntax.
581
- # In this case the block looks optional in most cases, so it marks optional.
582
- # In other cases, we can't determine which is required or optional, so it marks required.
583
- required: block != :&,
584
- type: Types::Function.empty(untyped)
585
- )
586
- end
587
-
588
- if body_node
589
- if (yields = any_node?(body_node) {|n| n.type == :YIELD })
590
- method_block = Types::Block.new(
591
- required: true,
592
- type: Types::Function.empty(untyped)
593
- )
594
-
595
- yields.each do |yield_node|
596
- array_content = yield_node.children[0]&.children&.compact || []
597
-
598
- positionals, keywords = if keyword_hash?(array_content.last)
599
- [array_content.take(array_content.size - 1), array_content.last]
600
- else
601
- [array_content, nil]
602
- end
603
-
604
- if (diff = positionals.size - method_block.type.required_positionals.size) > 0
605
- diff.times do
606
- method_block.type.required_positionals << Types::Function::Param.new(
607
- type: untyped,
608
- name: nil
609
- )
610
- end
611
- end
612
-
613
- if keywords
614
- keywords.children[0].children.each_slice(2) do |key_node, value_node|
615
- if key_node
616
- key = key_node.children[0]
617
- method_block.type.required_keywords[key] ||=
618
- Types::Function::Param.new(
619
- type: untyped,
620
- name: nil
621
- )
622
- end
623
- end
624
- end
625
- end
626
- end
627
- end
628
-
629
- method_block
630
- end
631
-
632
- # NOTE: args_node may be a nil by a bug
633
- # https://bugs.ruby-lang.org/issues/17495
634
- def args_from_node(args_node)
635
- args_node&.children || [0, nil, nil, nil, 0, nil, nil, nil, nil, nil]
636
- end
637
-
638
- def keyword_hash?(node)
639
- if node
640
- if node.type == :HASH
641
- node.children[0].children.compact.each_slice(2).all? {|key, _|
642
- key.type == :LIT && key.children[0].is_a?(Symbol)
643
- }
644
- end
645
- end
646
- end
647
-
648
- def any_node?(node, nodes: [], &block)
649
- if yield(node)
650
- nodes << node
651
- end
652
-
653
- each_child node do |child|
654
- any_node? child, nodes: nodes, &block
655
- end
656
-
657
- nodes.empty? ? nil : nodes
658
- end
659
-
660
561
  def node_type(node, default: Types::Bases::Any.new(location: nil))
661
562
  case node.type
662
563
  when :LIT
@@ -689,10 +590,6 @@ module RBS
689
590
  end
690
591
  end
691
592
 
692
- def untyped
693
- @untyped ||= Types::Bases::Any.new(location: nil)
694
- end
695
-
696
593
  def private
697
594
  @private ||= AST::Members::Private.new(location: nil)
698
595
  end
@@ -1,6 +1,8 @@
1
1
  module RBS
2
2
  module Prototype
3
3
  class Runtime
4
+ include Helpers
5
+
4
6
  attr_reader :patterns
5
7
  attr_reader :env
6
8
  attr_reader :merge
@@ -138,6 +140,8 @@ module RBS
138
140
  end
139
141
  end
140
142
 
143
+ block ||= block_from_ast_of(method)
144
+
141
145
  return_type = if method.name == :initialize
142
146
  Types::Bases::Void.new(location: nil)
143
147
  else
@@ -522,6 +526,18 @@ module RBS
522
526
  []
523
527
  end
524
528
  end
529
+
530
+ def block_from_ast_of(method)
531
+ return nil if RUBY_VERSION < '3.1'
532
+
533
+ begin
534
+ ast = RubyVM::AbstractSyntaxTree.of(method)
535
+ rescue ArgumentError
536
+ return # When the method is defined in eval
537
+ end
538
+
539
+ block_from_body(ast) if ast&.type == :SCOPE
540
+ end
525
541
  end
526
542
  end
527
543
  end
@@ -13,6 +13,7 @@ begin
13
13
  filter = ENV.fetch('RBS_TEST_TARGET', "").split(',').map! { |e| e.strip }
14
14
  skips = (ENV['RBS_TEST_SKIP'] || '').split(',').map! { |e| e.strip }
15
15
  RBS.logger_level = (ENV["RBS_TEST_LOGLEVEL"] || "info")
16
+ logger.level = RBS.logger_level
16
17
  sample_size = get_sample_size(ENV['RBS_TEST_SAMPLE_SIZE'] || '')
17
18
  double_class = to_double_class(ENV['RBS_TEST_DOUBLE_SUITE'])
18
19
  unchecked_classes = (ENV['RBS_TEST_UNCHECKED_CLASSES'] || '').split(',').map! { |unchecked_class| unchecked_class.strip }.push(*double_class)
data/lib/rbs/types.rb CHANGED
@@ -433,7 +433,7 @@ module RBS
433
433
  return "{ }" if self.fields.empty?
434
434
 
435
435
  fields = self.fields.map do |key, type|
436
- if key.is_a?(Symbol) && key.match?(/\A[A-Za-z_][A-Za-z_]*\z/) && !Parser::KEYWORDS.key?(key)
436
+ if key.is_a?(Symbol) && key.match?(/\A[A-Za-z_][A-Za-z_]*\z/) && !Parser::KEYWORDS.include?(key)
437
437
  "#{key}: #{type}"
438
438
  else
439
439
  "#{key.inspect} => #{type}"
@@ -690,7 +690,7 @@ module RBS
690
690
 
691
691
  def to_s
692
692
  if name
693
- if Parser::KEYWORDS.key?(name)
693
+ if Parser::KEYWORDS.include?(name)
694
694
  "#{type} `#{name}`"
695
695
  else
696
696
  "#{type} #{name}"
data/lib/rbs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RBS
2
- VERSION = "1.7.0.beta.2"
2
+ VERSION = "1.7.0"
3
3
  end
data/lib/rbs.rb CHANGED
@@ -32,6 +32,7 @@ require "rbs/constant"
32
32
  require "rbs/constant_table"
33
33
  require "rbs/ast/comment"
34
34
  require "rbs/writer"
35
+ require "rbs/prototype/helpers"
35
36
  require "rbs/prototype/rbi"
36
37
  require "rbs/prototype/rb"
37
38
  require "rbs/prototype/runtime"
@@ -68,5 +69,16 @@ module RBS
68
69
  @logger_level = level
69
70
  @logger = nil
70
71
  end
72
+
73
+ def print_warning()
74
+ @warnings ||= Set[]
75
+
76
+ message = yield()
77
+
78
+ unless @warnings.include?(message)
79
+ @warnings << message
80
+ logger.warn { message }
81
+ end
82
+ end
71
83
  end
72
84
  end
data/sig/parser.rbs CHANGED
@@ -6,6 +6,8 @@ module RBS
6
6
 
7
7
  def self.parse_signature: (Buffer | String, ?line: Integer, ?column: Integer) -> Array[AST::Declarations::t]
8
8
 
9
+ KEYWORDS: Hash[String, bot]
10
+
9
11
  private
10
12
 
11
13
  def self.buffer: (String | Buffer source) -> Buffer
data/sig/rbs.rbs CHANGED
@@ -8,6 +8,10 @@ module RBS
8
8
  def self.logger_output: () -> IO
9
9
 
10
10
  def self.logger_output=: (IO) -> IO
11
+
12
+ def self.print_warning: () { () -> String } -> void
13
+
14
+ self.@warnings: Set[String]
11
15
  end
12
16
 
13
17
  module Ruby
@@ -885,3 +885,47 @@ BigDecimal::SIGN_POSITIVE_ZERO: Integer
885
885
  # The version of bigdecimal library
886
886
  #
887
887
  BigDecimal::VERSION: String
888
+
889
+ module Kernel
890
+ private
891
+
892
+ # Create a new BigDecimal object.
893
+ #
894
+ # initial
895
+ # : The initial value, as an Integer, a Float, a Rational, a BigDecimal, or a
896
+ # String.
897
+ #
898
+ # If it is a String, spaces are ignored and unrecognized characters
899
+ # terminate the value.
900
+ #
901
+ # digits
902
+ # : The number of significant digits, as an Integer. If omitted or 0, the
903
+ # number of significant digits is determined from the initial value.
904
+ #
905
+ # The actual number of significant digits used in computation is usually
906
+ # larger than the specified number.
907
+ #
908
+ # exception
909
+ # : Whether an exception should be raised on invalid arguments. `true` by
910
+ # default, if passed `false`, just returns `nil` for invalid.
911
+ #
912
+ #
913
+ # #### Exceptions
914
+ #
915
+ # TypeError
916
+ # : If the `initial` type is neither Integer, Float, Rational, nor BigDecimal,
917
+ # this exception is raised.
918
+ #
919
+ # TypeError
920
+ # : If the `digits` is not an Integer, this exception is raised.
921
+ #
922
+ # ArgumentError
923
+ # : If `initial` is a Float, and the `digits` is larger than Float::DIG + 1,
924
+ # this exception is raised.
925
+ #
926
+ # ArgumentError
927
+ # : If the `initial` is a Float or Rational, and the `digits` value is
928
+ # omitted, this exception is raised.
929
+ #
930
+ def self?.BigDecimal: ((real | string | BigDecimal) initial, ?int digits, ?exception: bool) -> BigDecimal
931
+ end
data/stdlib/csv/0/csv.rbs CHANGED
@@ -360,6 +360,49 @@ class CSV < Object
360
360
  # output non-ASCII compatible data.
361
361
  #
362
362
  def self.generate: (?String str, **untyped options) { (CSV csv) -> void } -> String
363
+
364
+ # :call-seq:
365
+ # csv.each -> enumerator
366
+ # csv.each {|row| ...}
367
+ #
368
+ # Calls the block with each successive row.
369
+ # The data source must be opened for reading.
370
+ #
371
+ # Without headers:
372
+ # string = "foo,0\nbar,1\nbaz,2\n"
373
+ # csv = CSV.new(string)
374
+ # csv.each do |row|
375
+ # p row
376
+ # end
377
+ # Output:
378
+ # ["foo", "0"]
379
+ # ["bar", "1"]
380
+ # ["baz", "2"]
381
+ #
382
+ # With headers:
383
+ # string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
384
+ # csv = CSV.new(string, headers: true)
385
+ # csv.each do |row|
386
+ # p row
387
+ # end
388
+ # Output:
389
+ # <CSV::Row "Name":"foo" "Value":"0">
390
+ # <CSV::Row "Name":"bar" "Value":"1">
391
+ # <CSV::Row "Name":"baz" "Value":"2">
392
+ #
393
+ # ---
394
+ #
395
+ # Raises an exception if the source is not opened for reading:
396
+ # string = "foo,0\nbar,1\nbaz,2\n"
397
+ # csv = CSV.new(string)
398
+ # csv.close
399
+ # # Raises IOError (not opened for reading)
400
+ # csv.each do |row|
401
+ # p row
402
+ # end
403
+ def each: () -> Enumerator[untyped, Integer]
404
+ | () { (untyped) -> void } -> Integer
405
+
363
406
  end
364
407
 
365
408
  # The options used when no overrides are given by calling code. They are:
@@ -408,7 +451,7 @@ CSV::VERSION: String
408
451
  # processing is activated.
409
452
  #
410
453
  class CSV::Row < Object
411
- include Enumerable[untyped]
454
+ include Enumerable[Array[String]]
412
455
  extend Forwardable
413
456
 
414
457
  # If a two-element Array is provided, it is assumed to be a header and field and
@@ -464,7 +507,8 @@ class CSV::Row < Object
464
507
  #
465
508
  # Support for Enumerable.
466
509
  #
467
- def each: () { (*untyped) -> untyped } -> untyped
510
+ def each: () -> Enumerator[Array[String], self]
511
+ | () { (Array[String]) -> void } -> self
468
512
 
469
513
  alias each_pair each
470
514
 
@@ -717,7 +761,9 @@ class CSV::Table[out Elem] < Object
717
761
  #
718
762
  # If no block is given, an Enumerator is returned.
719
763
  #
720
- def each: () { (*untyped) -> untyped } -> untyped
764
+ def each: () -> Enumerator[untyped, self]
765
+ | () { (untyped) -> void } -> self
766
+ | () { (*untyped) -> void } -> self
721
767
 
722
768
  def empty?: (*untyped args) { (*untyped) -> untyped } -> untyped
723
769
 
@@ -0,0 +1,137 @@
1
+ class IO
2
+ class ConsoleMode
3
+ def echo=: (bool) -> bool
4
+ def raw: (?min: int, ?time: int, ?intr: bool) -> self
5
+ def raw!: (?min: int, ?time: int, ?intr: bool) -> self
6
+ end
7
+
8
+ # Returns an File instance opened console.
9
+ #
10
+ # If `sym` is given, it will be sent to the opened console with `args` and the
11
+ # result will be returned instead of the console IO itself.
12
+ def self.console: () -> File?
13
+ | (:close) -> nil
14
+ | (Symbol sym, *untyped args) -> untyped
15
+
16
+ # returns console window size
17
+ #
18
+ # You must require 'io/console/size' to use this method.
19
+ def self.console_size: () -> [Integer, Integer]
20
+
21
+ # fallback to console window size
22
+ #
23
+ # You must require 'io/console/size' to use this method.
24
+ def self.default_console_size: -> [Integer, Integer]
25
+
26
+ def beep: () -> self
27
+
28
+ def check_winsize_changed: () { () -> void } -> self
29
+ def clear_screen: () -> self
30
+
31
+ # Returns a data represents the current console mode.
32
+ def console_mode: () -> IO::ConsoleMode
33
+
34
+ # Sets the console mode to `mode`.
35
+ def console_mode=: (IO::ConsoleMode mode) -> IO::ConsoleMode
36
+
37
+ # Yields `self` within cooked mode.
38
+ #
39
+ # STDIN.cooked(&:gets)
40
+ #
41
+ # will read and return a line with echo back and line editing.
42
+ def cooked: [T] () { (self) -> T } -> T
43
+
44
+ # Enables cooked mode.
45
+ #
46
+ # If the terminal mode needs to be back, use io.cooked { ... }.
47
+ def cooked!: () -> self
48
+
49
+ def cursor: () -> [Integer, Integer]
50
+ def cursor=: ([Integer, Integer]) -> [Integer, Integer]
51
+
52
+ def cursor_down: (int) -> self
53
+ def cursor_left: (int) -> self
54
+ def cursor_right: (int) -> self
55
+ def cursor_up: (int) -> self
56
+
57
+ # Enables/disables echo back. On some platforms, all combinations of this flags
58
+ # and raw/cooked mode may not be valid.
59
+ def echo=: (bool flag) -> bool
60
+
61
+ # Returns `true` if echo back is enabled.
62
+ def echo?: () -> bool
63
+
64
+ def erase_line: (0 | 1 | 2 | nil) -> self
65
+ def erase_screen: (0 | 1 | 2 | 3 | nil) -> self
66
+
67
+ # Reads and returns a character in raw mode.
68
+ #
69
+ # See IO#raw for details on the parameters.
70
+ def getch: (?min: int, ?time: int, ?intr: bool) -> String
71
+
72
+ # Reads and returns a line without echo back.
73
+ # Prints +prompt+ unless it is +nil+.
74
+ #
75
+ # The newline character that terminates the
76
+ # read line is removed from the returned string,
77
+ # see String#chomp!.
78
+ def getpass: (?String) -> String
79
+
80
+ def goto: (int, int) -> self
81
+
82
+ def goto_column: (int) -> self
83
+
84
+ # Flushes input buffer in kernel.
85
+ def iflush: () -> self
86
+
87
+ # Flushes input and output buffers in kernel.
88
+ def ioflush: () -> self
89
+
90
+ # Yields `self` with disabling echo back.
91
+ #
92
+ # STDIN.noecho(&:gets)
93
+ #
94
+ # will read and return a line without echo back.
95
+ def noecho: [T] () { (self) -> T } -> T
96
+
97
+ # Flushes output buffer in kernel.
98
+ def oflush: () -> self
99
+
100
+ def pressed?: (Integer | Symbol | String) -> bool
101
+
102
+ # Yields `self` within raw mode, and returns the result of the block.
103
+ #
104
+ # STDIN.raw(&:gets)
105
+ #
106
+ # will read and return a line without echo back and line editing.
107
+ #
108
+ # The parameter `min` specifies the minimum number of bytes that should be
109
+ # received when a read operation is performed. (default: 1)
110
+ #
111
+ # The parameter `time` specifies the timeout in *seconds* with a precision of
112
+ # 1/10 of a second. (default: 0)
113
+ #
114
+ # If the parameter `intr` is `true`, enables break, interrupt, quit, and suspend
115
+ # special characters.
116
+ #
117
+ # Refer to the manual page of termios for further details.
118
+ def raw: [T] (?min: int, ?time: int, ?intr: bool) { (self) -> T } -> T
119
+
120
+ # Enables raw mode, and returns `io`.
121
+ #
122
+ # If the terminal mode needs to be back, use `io.raw { ... }`.
123
+ #
124
+ # See IO#raw for details on the parameters.
125
+ def raw!: (?min: int, ?time: int, ?intr: bool) -> self
126
+
127
+ def scroll_backward: (int) -> self
128
+ def scroll_forward: (int) -> self
129
+
130
+ # Returns console size.
131
+ def winsize: () -> [Integer, Integer]
132
+
133
+ # Tries to set console size. The effect depends on the platform and the running
134
+ # environment.
135
+ def winsize=: ([Integer, Integer]) -> [Integer, Integer]
136
+ | ([Integer, Integer, Integer, Integer]) -> [Integer, Integer, Integer, Integer]
137
+ end
@@ -1204,6 +1204,7 @@ module Net
1204
1204
 
1205
1205
  class HTTPRequest < HTTPGenericRequest
1206
1206
  def initialize: (String path, ?Hash[String, untyped] initheader) -> void
1207
+ | (URI::Generic uri, ?Hash[String, untyped] initheader) -> void
1207
1208
  end
1208
1209
 
1209
1210
  class HTTP::Get < HTTPRequest
@@ -1843,4 +1844,4 @@ module Net
1843
1844
  class HTTPFatalError < ProtoFatalError
1844
1845
  include Net::HTTPExceptions
1845
1846
  end
1846
- end
1847
+ end
@@ -95,8 +95,8 @@ class Tempfile < File
95
95
  # # ... do something with f ...
96
96
  # end
97
97
  #
98
- def self.create: (?String basename, ?String? tmpdir, ?mode: Integer, **untyped) -> File
99
- | [A] (?String basename, ?String? tmpdir, ?mode: Integer, **untyped) { (File) -> A } -> A
98
+ def self.create: (?(String | [String, String]) basename, ?String? tmpdir, ?mode: Integer, **untyped) -> File
99
+ | [A] (?(String | [String, String]) basename, ?String? tmpdir, ?mode: Integer, **untyped) { (File) -> A } -> A
100
100
 
101
101
  # Creates a new Tempfile.
102
102
  #
@@ -220,8 +220,6 @@ class Tempfile < File
220
220
  def initialize: (::Tempfile tmpfile) -> void
221
221
  end
222
222
 
223
- private
224
-
225
223
  # Creates a temporary file with permissions 0600 (= only readable and writable
226
224
  # by the owner) and opens it with mode "w+".
227
225
  #
@@ -265,6 +263,6 @@ class Tempfile < File
265
263
  # If Tempfile.new cannot find a unique filename within a limited number of
266
264
  # tries, then it will raise an exception.
267
265
  #
268
- def self.new: (?String basename, ?String? tmpdir, ?mode: Integer, **untyped) -> instance
269
- | [A] (?String basename, ?String? tmpdir, ?mode: Integer, **untyped) { (instance) -> A } -> A
266
+ def self.new: (?(String | [String, String]) basename, ?String? tmpdir, ?mode: Integer, **untyped) -> instance
267
+ | [A] (?(String | [String, String]) basename, ?String? tmpdir, ?mode: Integer, **untyped) { (instance) -> A } -> A
270
268
  end