rbs 4.0.0.dev.1 → 4.0.0.dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.clang-format +74 -0
  3. data/.clangd +2 -0
  4. data/.github/workflows/c-check.yml +51 -0
  5. data/.github/workflows/dependabot.yml +1 -1
  6. data/.github/workflows/ruby.yml +28 -17
  7. data/.github/workflows/typecheck.yml +0 -2
  8. data/.gitignore +4 -0
  9. data/.rubocop.yml +1 -1
  10. data/.vscode/extensions.json +5 -0
  11. data/.vscode/settings.json +19 -0
  12. data/README.md +37 -0
  13. data/Rakefile +90 -0
  14. data/config.yml +1 -1
  15. data/core/enumerable.rbs +9 -0
  16. data/core/io.rbs +4 -4
  17. data/core/thread.rbs +0 -7
  18. data/ext/rbs_extension/ast_translation.c +1010 -1074
  19. data/ext/rbs_extension/ast_translation.h +4 -0
  20. data/ext/rbs_extension/class_constants.c +78 -74
  21. data/ext/rbs_extension/class_constants.h +4 -0
  22. data/ext/rbs_extension/compat.h +10 -0
  23. data/ext/rbs_extension/extconf.rb +15 -1
  24. data/ext/rbs_extension/legacy_location.c +173 -172
  25. data/ext/rbs_extension/legacy_location.h +8 -3
  26. data/ext/rbs_extension/main.c +315 -273
  27. data/ext/rbs_extension/rbs_extension.h +3 -0
  28. data/ext/rbs_extension/rbs_string_bridging.h +4 -0
  29. data/include/rbs/ast.h +11 -12
  30. data/include/rbs/defines.h +11 -12
  31. data/include/rbs/lexer.h +108 -108
  32. data/include/rbs/location.h +14 -14
  33. data/include/rbs/parser.h +21 -19
  34. data/include/rbs/string.h +3 -3
  35. data/include/rbs/util/rbs_allocator.h +14 -14
  36. data/include/rbs/util/rbs_constant_pool.h +3 -3
  37. data/include/rbs/util/rbs_encoding.h +1 -1
  38. data/lib/rbs/environment.rb +4 -0
  39. data/lib/rbs/namespace.rb +0 -7
  40. data/lib/rbs/parser_aux.rb +5 -0
  41. data/lib/rbs/type_name.rb +0 -7
  42. data/lib/rbs/types.rb +3 -1
  43. data/lib/rbs/unit_test/convertibles.rb +1 -0
  44. data/lib/rbs/version.rb +1 -1
  45. data/sig/environment.rbs +3 -0
  46. data/sig/namespace.rbs +0 -5
  47. data/sig/parser.rbs +20 -0
  48. data/sig/typename.rbs +0 -5
  49. data/sig/types.rbs +4 -1
  50. data/src/ast.c +216 -214
  51. data/src/lexer.c +2923 -2675
  52. data/src/lexstate.c +157 -157
  53. data/src/location.c +40 -40
  54. data/src/parser.c +2591 -2586
  55. data/src/string.c +2 -2
  56. data/src/util/rbs_allocator.c +7 -9
  57. data/src/util/rbs_assert.c +9 -9
  58. data/src/util/rbs_constant_pool.c +5 -7
  59. data/src/util/rbs_encoding.c +20095 -4056
  60. data/src/util/rbs_unescape.c +33 -32
  61. data/stdlib/json/0/json.rbs +9 -43
  62. data/stdlib/ripper/0/ripper.rbs +3 -0
  63. data/stdlib/socket/0/addrinfo.rbs +2 -2
  64. metadata +8 -2
data/lib/rbs/types.rb CHANGED
@@ -1339,8 +1339,10 @@ module RBS
1339
1339
  attr_reader :type
1340
1340
  attr_reader :required
1341
1341
  attr_reader :self_type
1342
+ attr_reader :location
1342
1343
 
1343
- def initialize(type:, required:, self_type: nil)
1344
+ def initialize(location: nil, type:, required:, self_type: nil)
1345
+ @location = location
1344
1346
  @type = type
1345
1347
  @required = required ? true : false
1346
1348
  @self_type = self_type
@@ -5,6 +5,7 @@ module RBS
5
5
  module Convertibles
6
6
  class BlankSlate < BasicObject
7
7
  instance_methods.each do |im|
8
+ next if im == :__id__
8
9
  next if im == :__send__
9
10
  undef_method im
10
11
  end
data/lib/rbs/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RBS
4
- VERSION = "4.0.0.dev.1"
4
+ VERSION = "4.0.0.dev.3"
5
5
  end
data/sig/environment.rbs CHANGED
@@ -30,6 +30,9 @@ module RBS
30
30
  class GlobalEntry < SingleEntry[Symbol, AST::Declarations::Global]
31
31
  end
32
32
 
33
+ # Top level declarations
34
+ def declarations: () -> Array[AST::Ruby::Declarations::t | AST::Declarations::t]
35
+
33
36
  # Array of source objects loaded in the environment
34
37
  #
35
38
  attr_reader sources: Array[Source::t]
data/sig/namespace.rbs CHANGED
@@ -139,8 +139,3 @@ module RBS
139
139
  | () -> Enumerator[Namespace, void]
140
140
  end
141
141
  end
142
-
143
- module Kernel
144
- # Deprecated: Use `RBS::Namespace.parse` instead
145
- %a{deprecated} def Namespace: (String) -> RBS::Namespace
146
- end
data/sig/parser.rbs CHANGED
@@ -68,6 +68,24 @@ module RBS
68
68
  #
69
69
  def self.parse_signature: (Buffer | String) -> [Buffer, Array[AST::Directives::t], Array[AST::Declarations::t]]
70
70
 
71
+ # Parse a list of type parameters and return it
72
+ #
73
+ # ```ruby
74
+ # RBS::Parser.parse_type_params("") # => nil
75
+ # RBS::Parser.parse_type_params("[U, V]") # => `[:U, :V]`
76
+ # RBS::Parser.parse_type_params("[in U, V < Integer]") # => `[:U, :V]`
77
+ # ```
78
+ #
79
+ # When `module_type_params` is `false`, an error is raised if `unchecked`, `in` or `out` are used.
80
+ #
81
+ # ```ruby
82
+ # RBS::Parser.parse_type_params("[unchecked U]", module_type_params: false) # => Raises an error
83
+ # RBS::Parser.parse_type_params("[out U]", module_type_params: false) # => Raises an error
84
+ # RBS::Parser.parse_type_params("[in U]", module_type_params: false) # => Raises an error
85
+ # ```
86
+ #
87
+ def self.parse_type_params: (Buffer | String, ?module_type_params: bool) -> Array[AST::TypeParam]
88
+
71
89
  # Returns the magic comment from the buffer
72
90
  #
73
91
  def self.magic_comment: (Buffer) -> AST::Directives::ResolveTypeNames?
@@ -104,6 +122,8 @@ module RBS
104
122
 
105
123
  def self._parse_signature: (Buffer, Integer start_pos, Integer end_pos) -> [Array[AST::Directives::t], Array[AST::Declarations::t]]
106
124
 
125
+ def self._parse_type_params: (Buffer, Integer start_pos, Integer end_pos, bool module_type_params) -> Array[AST::TypeParam]
126
+
107
127
  def self._lex: (Buffer, Integer end_pos) -> Array[[Symbol, Location[untyped, untyped]]]
108
128
 
109
129
  def self._parse_inline_leading_annotation: (Buffer, Integer start_pos, Integer end_pos, Array[Symbol] variables) -> AST::Ruby::Annotations::leading_annotation
data/sig/typename.rbs CHANGED
@@ -72,8 +72,3 @@ module RBS
72
72
  def self.parse: (String name) -> RBS::TypeName
73
73
  end
74
74
  end
75
-
76
- module Kernel
77
- # Deprecated: Use `RBS::TypeName.parse` instead
78
- %a{deprecated: Use `RBS::TypeName.parse` instead} def TypeName: (String name) -> RBS::TypeName
79
- end
data/sig/types.rbs CHANGED
@@ -518,7 +518,10 @@ module RBS
518
518
 
519
519
  attr_reader self_type: t?
520
520
 
521
- def initialize: (type: function, ?self_type: t?, required: boolish) -> void
521
+ type loc = Location[bot, bot]
522
+ attr_reader location: loc?
523
+
524
+ def initialize: (?location: loc?, type: function, ?self_type: t?, required: boolish) -> void
522
525
 
523
526
  def ==: (untyped other) -> bool
524
527