Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/compiler/crystal/macros.cr
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,24 @@ private macro def_string_methods(klass)
def lines : ArrayLiteral(StringLiteral)
end

# Similar to `String#split`.
# Similar to `String#split()`.
def split : ArrayLiteral(StringLiteral)
end

# Similar to `String#split`.
# Similar to `String#split(String)`.
def split(node : StringLiteral) : ArrayLiteral(StringLiteral)
end

# Similar to `String#split(Char)`.
def split(node : CharLiteral) : ArrayLiteral(StringLiteral)
end

# Similar to `String#split(Regex)`.
def split(node : RegexLiteral) : ArrayLiteral(StringLiteral)
end

# Similar to `String#split(String)`.
@[Deprecated("Use `#split(StringLiteral)` instead")]
def split(node : ASTNode) : ArrayLiteral(StringLiteral)
end

Expand Down
1 change: 1 addition & 0 deletions src/compiler/crystal/macros/methods.cr
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ module Crystal
when RegexLiteral
splitter = regex_value(arg)
else
interpreter.warnings.add_warning_at(name_loc, "Deprecated StringLiteral#split(ASTNode). Use `#split(StringLiteral)` instead")
splitter = arg.to_s
end

Expand Down