Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix documentation for #[]= macro methods #10025

Merged
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
6 changes: 3 additions & 3 deletions src/compiler/crystal/macros.cr
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ module Crystal::Macros
end

# Similar to `Array#[]=`.
def []=(index : NumberLiteral, value : ASTNode)
def []=(index : NumberLiteral, value : ASTNode) : ASTNode
end

# Similar to `Array#unshift`.
Expand Down Expand Up @@ -760,7 +760,7 @@ module Crystal::Macros
end

# Similar to `Hash#[]=`
def []=(key : ASTNode) : ASTNode
def []=(key : ASTNode, value : ASTNode) : ASTNode
end

# Returns the type specified at the end of the Hash literal, if any.
Expand Down Expand Up @@ -835,7 +835,7 @@ module Crystal::Macros
end

# Adds or replaces a key.
def []=(key : SymbolLiteral | StringLiteral | MacroId) : ASTNode
def []=(key : SymbolLiteral | StringLiteral | MacroId, value : ASTNode) : ASTNode
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/macros/methods.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2456,7 +2456,7 @@ private def interpret_array_or_tuple_method(object, klass, method, args, block,
index += object.elements.size if index < 0

unless 0 <= index < object.elements.size
index_node.raise "index out of bounds (index: #{index}, size: #{object.elements.size}"
index_node.raise "index out of bounds (index: #{index}, size: #{object.elements.size})"
end

object.elements[index] = value
Expand Down