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
21 changes: 16 additions & 5 deletions io_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1684,11 +1684,14 @@ io_buffer_validate_range(struct rb_io_buffer *buffer, size_t offset, size_t leng
}

/*
* call-seq: hexdump([offset, [length, [width]]]) -> string
* call-seq: hexdump([offset, [length, [width]]]) -> string or nil
*
* Returns a human-readable string representation of the buffer. The exact
* format is subject to change.
*
* Returns +nil+ if the buffer does not reference any memory, that is, if
* #null? returns +true+ (for example after #free or #transfer).
*
* buffer = IO::Buffer.for("Hello World")
* puts buffer.hexdump
* # 0x00000000 48 65 6c 6c 6f 20 57 6f 72 6c 64 Hello World
Expand Down Expand Up @@ -1961,10 +1964,18 @@ io_buffer_resize(VALUE self, VALUE size)
}

/*
* call-seq: <=>(other) -> true or false
* call-seq: <=>(other) -> integer
*
* Returns a negative integer, zero, or a positive integer if the receiver is
* less than, equal to, or greater than +other+, respectively.
*
* Buffers are compared by size first, and if the sizes are equal, by the exact
* contents of the memory they are referencing using +memcmp+. Only the sign of
* the returned integer is meaningful; the result of +memcmp+ is returned as is.
*
* Buffers are compared by size and exact contents of the memory they are
* referencing using +memcmp+.
* IO::Buffer.for("abc") <=> IO::Buffer.for("abc") # => 0
* IO::Buffer.for("abc") <=> IO::Buffer.for("ab") # => 1
* IO::Buffer.for("abc") <=> IO::Buffer.for("abd") # => -1
*/
static VALUE
rb_io_buffer_compare(VALUE self, VALUE other)
Expand Down Expand Up @@ -3540,7 +3551,7 @@ memory_and(unsigned char * restrict output, const unsigned char * restrict base,
*
* IO::Buffer.for("1234567890") & IO::Buffer.for("\xFF\x00\x00\xFF")
* # =>
* # #<IO::Buffer 0x00005589b2758480+4 INTERNAL>
* # #<IO::Buffer 0x00005589b2758480+10 INTERNAL>
* # 0x00000000 31 00 00 34 35 00 00 38 39 00 1..45..89.
*/
static VALUE
Expand Down
9 changes: 8 additions & 1 deletion lib/prism/translation/parser/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,14 @@ def visit_assoc_node(node)
else
parts =
if key.is_a?(SymbolNode)
[builder.string_internal([key.unescaped, srange(key.value_loc)])]
value_loc = key.value_loc
if value_loc.nil?
[]
elsif value_loc.slice.include?("\n")
string_nodes_from_line_continuations(key.unescaped, value_loc.slice, value_loc.start_offset, key.opening)
else
[builder.string_internal([key.unescaped, srange(value_loc)])]
end
else
visit_all(key.parts)
end
Expand Down
11 changes: 2 additions & 9 deletions prism/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -22403,11 +22403,7 @@ parse_expression_terminator(pm_parser_t *parser, pm_node_t *node) {
// A block call (command with do-block, or any call chained
// from one) can only be followed by call chaining (., ::,
// &.), composition (and/or), and modifier operators.
if (pm_block_call_p(node)) {
return left > PM_BINDING_POWER_COMPOSITION && left < PM_BINDING_POWER_CALL;
}

return false;
return left > PM_BINDING_POWER_COMPOSITION && left < PM_BINDING_POWER_CALL && pm_block_call_p(node);
}
case PM_SUPER_NODE:
case PM_YIELD_NODE:
Expand All @@ -22419,10 +22415,7 @@ parse_expression_terminator(pm_parser_t *parser, pm_node_t *node) {

/* A super carrying a do-block is a block call, so it may also be
* followed by call chaining (`.`, `::`, `&.`). */
if (pm_block_call_p(node)) {
return left > PM_BINDING_POWER_COMPOSITION && left < PM_BINDING_POWER_CALL;
}
return false;
return left > PM_BINDING_POWER_COMPOSITION && left < PM_BINDING_POWER_CALL && pm_block_call_p(node);
case PM_DEF_NODE:
// An endless method whose body is a command-style call (e.g.,
// `def f = foo bar`) is a command assignment and can only be
Expand Down
6 changes: 6 additions & 0 deletions test/prism/fixtures/hashes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ tap do
end

{ a: -1 }

{ "": nil}

{ "foo
bar": nil}