Skip to content

Commit

Permalink
Deprecate Kernel#Namespace
Browse files Browse the repository at this point in the history
Namespace functionality will be added in Ruby4.
If added, `Namespace()` is likely to create confusion.
  • Loading branch information
ksss authored and soutaro committed Dec 18, 2024
1 parent 1877ae5 commit c8b02bf
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/rbs/namespace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ def ascend

module Kernel
def Namespace(name)
warn "Kernel#Namespace() is deprecated. Use RBS::Namespace.parse instead.", category: :deprecated
RBS::Namespace.parse(name)
end
end
5 changes: 2 additions & 3 deletions sig/namespace.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ module RBS
end

module Kernel
# Parses given string and returns Namespace.
#
def Namespace: (String) -> RBS::Namespace
# Deprecated: Use `RBS::Namespace.parse` instead
%a{steep:deprecated} def Namespace: (String) -> RBS::Namespace
end
2 changes: 1 addition & 1 deletion test/rbs/signature_parsing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2153,7 +2153,7 @@ class Foo
end

use.clauses[1].tap do |clause|
assert_equal Namespace("RBS::AST::Declarations::"), clause.namespace
assert_equal RBS::Namespace.parse("RBS::AST::Declarations::"), clause.namespace
assert_equal "RBS::AST::Declarations::", clause.location[:namespace].source
assert_equal "*", clause.location[:star].source
end
Expand Down
2 changes: 1 addition & 1 deletion test/rbs/use_map_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_import_single_clause
end

def test_import_wildcard_clause
map.build_map(Use::WildcardClause.new(namespace: Namespace("Foo::"), location: nil))
map.build_map(Use::WildcardClause.new(namespace: RBS::Namespace.parse("Foo::"), location: nil))

assert_equal TypeName("::Foo::M"), map.resolve?(TypeName("M"))
assert_equal TypeName("::Foo::_I"), map.resolve?(TypeName("_I"))
Expand Down

0 comments on commit c8b02bf

Please sign in to comment.