This function has been used wrongly always at first, "allocate a
buffer then wrap it with tmpbuf". This order can cause a memory
leak, as tmpbuf creation also can raise a NoMemoryError exception.
The right order is "create a tmpbuf then allocate&wrap a buffer".
So the argument of this function is rather harmful than just
useless.
TODO:
* Rename this function to more proper name, as it is not used
"temporary" (function local) purpose.
* Allocate and wrap at once safely, like `ALLOCV`.
The parser needs to determine whether a local varaiable is defined or
not in outer scope. For the sake, "base_block" field has kept the outer
block.
However, the whole block was actually unneeded; the parser used only
base_block->iseq.
So, this change lets parser_params have the iseq directly, instead of
the whole block.
The relation between parser_param#base_block and #in_main were very
subtle.
A main script (that is passed via a command line) was parsed under
base_block = TOPLEVEL_BINDING and in_main = 1.
A script loaded by Kernel#require was parsed under
base_block = NULL and in_main = 0.
If base_block is non-NULL and in_main == 0, it is parsed by Kernel#eval
or family.
However, we know that TOPLEVEL_BINDING has no local variables when a
main script is parsed. So, we don't have to parse a main script under
base_block = TOPLEVEL_BINDING.
Instead, this change parses a main script under base_block = 0.
If base_block is non-NULL, it is parsed by Kernel#eval or family.
By this simplication, "in_main" is no longer needed.
We are seeing SEGVs in CI:
http://ci.rvm.jp/results/trunk-gc-asserts@ruby-sky1/2253563
This is happening because Ripper constructs AST nodes differently than
parse.y normally does. Specifically in this case Ripper is assigning 3
`VALUE` objects:
1febb6f4a1/parse.y (L757-L761)
Where parse.y will normally assign other things:
1febb6f4a1/parse.y (L11258-L11260)
The important one is the last one, the `struct rb_ary_pattern_info`. The
mark function assumed that `NODE_ARYPTN` have a pointer to `struct
rb_ary_pattern_info`, and used it:
1febb6f4a1/node.c (L1269-L1274)
In the case of Ripper, `NODE_ARYPTN` doesn't point to an
`rb_ary_pattern_info`, so the mark function would SEGV. This commit
changes Ripper so that its `NODE_ARYPTN` nodes also point at an
`rb_ary_pattern_info`, and the mark function can continue with the same
assumption.
Macros can't be expressions, that is a GNU extension (I didn't know
that). This commit converts the macro to a function so that everything
will compile correctly on non-GNU compatible compilers.
This patch changes parse.y to only use `add_mark_object` in Ripper.
Previously we were seeing a bug in write barrier verification. I had
changed `add_mark_object` to execute the write barrier, but the problem
is that we had code like this:
```
NEW_STR(add_mark_object(p, obj), loc)
```
In this case, `add_mark_object` would execute the write barrier between
the ast and `obj`, but the problem is that `obj` isn't actually
reachable from the AST at the time the write barrier executed.
`NEW_STR` can possibly call `malloc` which can kick a GC, and since
`obj` isn't actually reachable from the AST at the time of WB execution,
verification would fail.
Basically the steps were like this:
1. RB_OBJ_WRITTEN via `add_mark_object`
2. Allocate node
3. *Possibly* execute GC via malloc
4. Write obj in to allocated node
This patch changes the steps to:
1. Allocate node
2. *Possibly* execute GC via malloc
3. Write obj in to allocated node
4. RB_OBJ_WRITTEN
and NODE_ZARRAY to NODE_ZLIST.
NODE_ARRAY is used not only by an Array literal, but also the contents
of Hash literals, method call arguments, dynamic string literals, etc.
In addition, the structure of NODE_ARRAY is a linked list, not an array.
This is very confusing, so I believe `NODE_LIST` is a better name.
I guess those AST node were actually used for something, so we'd better
not touch them. Instead this commit just puts the tmpbuffer inside a
different internal struct so that we can mark them.
This commit adds two buckets for allocating NODE structs, then allocates
"markable" NODE objects from one bucket. The reason to do this is so
when the AST mark function scans nodes for VALUE objects to mark, we
only scan NODE objects that we know to reference VALUE objects. If we
*did not* divide the objects, then the mark function spends too much
time scanning objects that don't contain any references.
Now we can reach the ID table buffer from the id table itself, so when
SCOPE nodes are marked we can keep the buffers alive. This eliminates
the need for the "mark array" during normal parse / compile (IOW *not*
Ripper).
This patch changes the AST mark function so that it will walk through
nodes in the NODE buffer marking Ruby objects rather than using a mark
array to guarantee liveness. The reason I want to do this is so that
when compaction happens on major GCs, node objects will have their
references pinned (or possibly we can update them correctly).
This is broken at least since 2.5 (I didn't check earlier versions).
It resulted in failure in test_ast.rb when the tests were added before
the parser change.
Basically, in remove_duplicate_keys, if the node is modified, set
the location information to the previous location information. The
removal of keys should not affect the location in the code.
Previously, **{} was removed by the parser:
```
$ ruby --dump=parse -e '{**{}}'
@ NODE_SCOPE (line: 1, location: (1,0)-(1,6))
+- nd_tbl: (empty)
+- nd_args:
| (null node)
+- nd_body:
@ NODE_HASH (line: 1, location: (1,0)-(1,6))*
+- nd_brace: 1 (hash literal)
+- nd_head:
(null node)
```
Since it was removed by the parser, the compiler did not know
about it, and `m(**{})` was therefore treated as `m()`.
This modifies the parser to not remove the `**{}`. A simple
approach for this is fairly simple by just removing a few
lines from the parser, but that would cause two hash
allocations every time it was used. The approach taken here
modifies both the parser and the compiler, and results in `**{}`
not allocating any hashes in the usual case.
The basic idea is we use a literal node in the parser containing
a frozen empty hash literal. In the compiler, we recognize when
that is used, and if it is the only keyword present, we just
push it onto the VM stack (no creation of a new hash or merging
of keywords). If it is the first keyword present, we push a
new empty hash onto the VM stack, so that later keywords can
merge into it. If it is not the first keyword present, we can
ignore it, since the there is no reason to merge an empty hash
into the existing hash.
Example instructions for `m(**{})`
Before (note ARGS_SIMPLE):
```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,7)> (catch: FALSE)
0000 putself ( 1)[Li]
0001 opt_send_without_block <callinfo!mid:m, argc:0, FCALL|ARGS_SIMPLE>, <callcache>
0004 leave
```
After (note putobject and KW_SPLAT):
```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,7)> (catch: FALSE)
0000 putself ( 1)[Li]
0001 putobject {}
0003 opt_send_without_block <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache>
0006 leave
```
Example instructions for `m(**h, **{})`
Before and After (no change):
```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE)
0000 putself ( 1)[Li]
0001 putspecialobject 1
0003 newhash 0
0005 putself
0006 opt_send_without_block <callinfo!mid:h, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
0009 opt_send_without_block <callinfo!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE>, <callcache>
0012 opt_send_without_block <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache>
0015 leave
```
Example instructions for `m(**{}, **h)`
Before:
```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE)
0000 putself ( 1)[Li]
0001 putspecialobject 1
0003 newhash 0
0005 putself
0006 opt_send_without_block <callinfo!mid:h, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
0009 opt_send_without_block <callinfo!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE>, <callcache>
0012 opt_send_without_block <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache>
0015 leave
```
After (basically the same except for the addition of swap):
```
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,12)> (catch: FALSE)
0000 putself ( 1)[Li]
0001 newhash 0
0003 putspecialobject 1
0005 swap
0006 putself
0007 opt_send_without_block <callinfo!mid:h, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
0010 opt_send_without_block <callinfo!mid:core#hash_merge_kwd, argc:2, ARGS_SIMPLE>, <callcache>
0013 opt_send_without_block <callinfo!mid:m, argc:1, FCALL|KW_SPLAT>, <callcache>
0016 leave
```
This reverts the changes to parse.y in
a5b37262524ac39d2af13eea174486370a581c23 as they are not actually
needed and cause the warning for duplicate hash keys to not be
emitted.
The on_params hook will use :nil as the keyword rest argument.
There is a new on_nokw_param hook as well.
This fixes a type issue in the previous code, where an ID was
passed where a VALUE was the declared type. The symbol :nil is
passed instead of the id.
This syntax means the method should be treated as a method that
uses keyword arguments, but no specific keyword arguments are
supported, and therefore calling the method with keyword arguments
will raise an ArgumentError. It is still allowed to double splat
an empty hash when calling the method, as that does not pass
any keyword arguments.
`rb_ast_t` holds a reference to this object, so it should mark the
object. Currently it is relying on the `mark_ary` on `node_buffer` to
ensure that the object stays alive. But since the array internals can
move, this could cause a segv if compaction impacts the array.
Single assignment with rescue modifier applies rescue to the RHS:
a = raise rescue 1 # a = (raise rescue 1)
Previously, multiple assignment with rescue modifier applied rescue
to the entire expression:
a, b = raise rescue [1, 2] # (a, b = raise) rescue [1, 2]
This makes multiple assignment with rescue modifier consistent with
single assignment with rescue modifier, applying rescue to the RHS:
a, b = raise rescue [1, 2] # a, b = (raise rescue [1, 2])
Implements [Feature #8239]
Fixes [Bug #8279]
* parse.y (yycompile): make sure in advance that the `__FILE__`
object shares a fstring, to get rid of dangling path name.
Fixed up 53e9908d8a. [Bug #16041]
* vm_eval.c (eval_make_iseq): ditto.
As a comment token includes the newline, so delayed newline token
just follows it should not be dispatched. [Bug #11485]
Co-Authored-By: Jeremy Evans <code@jeremyevans.net>
* parse.y (value_expr_check): if either of `then` or `else`
statements is not a void value expression, the whole `if` is not
also a void value expression. [Bug #15932]
* string.c (str_replace_shared_without_enc): free previous buffer
before replaced.
* parse.y (gettable): make sure in advance that the `__FILE__`
object shares a fstring, to get rid of replacement with the
fstring later.
TODO: this hack may be needed in other places.
[Bug #15916]
Co-Authored-By: luke-gru (Luke Gruber) <luke.gru@gmail.com>
`(ID)1` was assigned to NODE_ARGS#rest_arg for `{|x,| }`.
This change removes the magic number by introducing an explicit macro
variable for it: NODE_SPECIAL_EXCESSED_COMMA.
Terminate the input from a TTY by 2 ^D at the middle of line, like
as many programs, `cat`, `perl` and so on, do. By the first ^D,
the line will be sent without a newline, and then EOF will be send
by the next ^D.
* parse.y (here_document): broke the terminator condition down
into each piece, the positional condition, resetting the
dedented here-document indentation, and matching identifier.
suppress a false warning by icc.
Heredocs are parsed line-by-line, so we need to keep track of the
temporary encoding of the string. Previously, a heredoc would
only detect mixed encoding errors if they were on the same line,
this changes things so they will be caught on different lines.
Fixes [Bug #15839]
This allows cases such as:
```ruby
m ->(a = ->{@1}) {a}
m.call.call(1)
m2 ->(a: ->{@1}) {a}
m2.call.call(2)
```
Previously, this would cause a syntax error.
[Bug#15789]
Because `proc{|| @1}` is a syntax error, the following should
also be syntax errors:
```ruby
proc { |
| @1}
```
```ruby
proc { |; a| @1 }
```
This fixes both cases.
[Bug #15825]
* parse.y (heredoc_identifier): CR in here-document identifier
might or might not result in a syntax error, by the EOL code.
make a syntax error regardless of the EOL code.
* parse.y (heredoc_identifier): quoted here-document identifier
must end within the same line.
the only corner case that here-document identifier can contain a
newline is that the closing qoute is placed at the beginning of
the next line, and has been warned since 2.4.
```ruby
<<"EOS
" # warning: here document identifier ends with a newline
EOS
```
* parse.y (internal_id): number the ID serial for internal use by
counting down from the neary maximum value, not to accidentally
match permanent IDs.
[Bug #15768]
* parse.y (parser_append_options): explicitly pass $; when auto
splitting, to suppress the warning for non-nil $;.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (rb_parser_fatal): fix "parser" in the message which was
replaced accidentally. it is not the argument name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Because hard to specify commits related to r67479 only.
So please commit again.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (rb_parser_fatal): fix "parser" in the message which was
replaced accidentally. it is not the argument name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: show compile error and the error line separately,
instead of building the error message by snprintf then yyerror.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (parser_token_value_print): in ripper, ID values are
wrapped in NODE_RIPPER at set_yylval_name(), so print the Symbol
wrapped together.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67305 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (lambda): support numbered parameters, only when no
argument list including empty parentheses, like empty vertical
bars. [ruby-core:91859] [Bug #15672]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67295 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (set_yylval_noname): continue after an invalid global,
instance, class variable name, without "unexpected end-of-file"
error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (parser_numbered_param): hoisted out the contextual
check for numbered parameters.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67289 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (parse_atmark): exclude punctuation follows @ marks,
whereas it is inclusive after $ mark as some punctuation global
variables exist.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (parse_gvar): show the source line erred by invalid
global variable, and indicate the variable including the wrong
punctuation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (ruby_show_error_line): hoisted out from parser_yyerror.
* parse.y (regx_options): revert r67226 and show the error line
separately.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (parser_yyerror): trim a newline at the end of the erred
code which was replaced with an extra space in the succeeding
cursor line.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (parse_string): bail out when word-list meets end of
input not to show an extra "unexpected" error message after the
preceding error.
$ ruby -e "%w["
-e:1: unterminated string meets end of file
-e:1: syntax error, unexpected terminator, expecting ' '
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
yystpcpy is always used by yysyntax_error in bison 2.3, but may
not used by other than yytnamerr in newer bison.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (rb_yytnamerr): strip enclosing double-quotes, same as
the default yytnamerr except for that single-quotes matching
back-quotes do not stop stripping.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (symbol): turned into a node, as well as `numeric`, for
a symbol literal, and includes `dsym` now.
* parse.y (ssym): previous `symbol`. renamed as the counterpart
of `dsym`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: refine error messages for tSYMBEG and tSTRING_BEG, which
can appear at invalid places.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: Fix the beginning position of trailing NODE_UNDEF.
e.g. The location of the NODE_UNDEF for `b` is fixed:
```
undef a, b
```
* Before
```
NODE_UNDEF (line: 1, location: (1,6)-(1,10))
```
* After
```
NODE_UNDEF (line: 1, location: (1,9)-(1,10))
```
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
which usually refers ruby_sourcefile_string and is not freed
directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (heredoc_dedent): manage the last node of NODE_ARRAY,
when concatenating dedented literals.
[ruby-core:89649] [Bug #15272]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (command): set the last location from the location
managed by bison, so that other nodes are not needed.
[ruby-core:89648] [Bug #15271]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
You can now write the following without warning.
user = User.all.find {|user| cond(user) }
Fixes [Feature #12490].
A patch from Soutaro Matsumoto <matsumoto@soutaro.com>.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
You can now write the following without warning.
user = User.all.find {|user| cond(user) }
Fixes [Feature #12490].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: Fix to start with the argument.
e.g. The locations of the NODE_SCOPE is fixed:
```
-> x { 1 + 2 }
```
* Before
```
NODE_SCOPE (line: 1, location: (1,2)-(1,14))
```
* After
```
NODE_SCOPE (line: 1, location: (1,3)-(1,14))
```
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* node.h: Add `nd_first_loc` and `nd_set_first_loc`
* parse.y: Fix to start with the beginning of `->` .
e.g. The locations of the NODE_LAMBDA is fixed:
```
-> x { 1 + 2 }
```
* Before
```
NODE_LAMBDA (line: 1, location: (1,2)-(1,14))
```
* After
```
NODE_LAMBDA (line: 1, location: (1,0)-(1,14))
```
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (arg_blk_pass): preceeding arguments node may be NULL when
an empty keyword argument hash splat is optimized away.
[ruby-core:88890] [Bug #15087]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Because of the lack of this case, `[*ary,1,2,3,4,5,6]` was parsed into
an inefficient AST like `ary + [1,2] + [3,4] + [5,6]`.
A patch from Anmol Chopra <anmolchopra@rocketbox.in>.
Fixes [Bug #15018].
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
The code fragments that initializes coverage data were scattered into
both parse.y and compile.c. parse.y allocated a coverage data, and
compile.c initialize the data.
To remove this cross-cutting concern, this change moves the allocation
from "coverage" function of parse.y to "rb_iseq_new_top" of iseq.c.
For the sake, parse.y just counts the line number of the original source
code, and the number is passed via rb_ast_body_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Now endless range can be created by either a literal `(1..)` or explicit
range creation `Range.new(1, nil)`. [Bug #14845]
This change is intended for "early failure"; for example,
`(1..var).to_a` causes out of memory if `var` is inadvertently nil.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
When an empty rule or a mid-rule action is reduced,
`YYLLOC_DEFAULT` is called with the third parameter to be zero.
If we use `RUBY_SET_YYLLOC_OF_NONE` to set their locations,
sometimes the end position of NODE indicates a blank.
For example, `a.b ;` generates `NODE_CALL (line: 1, location: (1,0)-(1,4))*`,
whose end position indicates a blank.
This is because of the following reasons:
* `NODE_CALL` is created when `primary_value call_op operation2 opt_paren_args` is
reduced to `method_call`.
* `opt_paren_args` is `none`.
* `yylex` is called and `lex.pbeg` moves before `none` is reduced, so
the beginning position of `none` does not match with the end position of `operation2`.
To fix locations, use `YYRHSLOC(Rhs, 0)` in `YYLLOC_DEFAULT`
(0 "refers to the symbol just before the reduction").
By this change, the bottom of the location stack would be referenced,
so initialize the bottom with `RUBY_SET_YYLLOC_OF_NONE` in `%initial-action`.
Ref: https://www.gnu.org/software/bison/manual/html_node/Location-Default-Action.html#Location-Default-Action
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (new_bodystmt): Fix locations of NODE_RESCUE
to end with nd_else or nd_resq. Before this commit,
locations of NODE_RESCUE included locations of nd_ensr
of NODE_ENSURE which is a parent node of NODE_RESCUE.
e.g. The location of the end of NODE_RESCUE is fixed:
```
def a
:b
rescue
:c
ensure
:d
end
```
* Before
```
NODE_RESCUE (line: 2, location: (2,2)-(6,4))
```
* After
```
NODE_RESCUE (line: 3, location: (2,2)-(5,0))
```
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Another part of the plan to reduce dependencies on malloc_usable_size
which costs us speed: https://bugs.ruby-lang.org/issues/10238
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
No automatic type promotion is expected for variadic arguments.
You have to do it by hand.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (cond0): do not warn literal boolean (true and false) in
condition expressions, as they are often used as infinite loops,
deactivated code block, etc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63457 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (primary, new_args_tail, local_tbl): keep the order;
allocate an empty imemo first then xmalloc, to get rid of
potential memory leak when allocation imemo failed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: Fix to start with the end of dots.
e.g. The locations of the NODE_NIL is fixed:
```
1..
```
* Before
```
NODE_NIL (line: 1, location: (1,0)-(1,3))
```
* After
```
NODE_NIL (line: 1, location: (1,3)-(1,3))
```
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* gc.c (rb_alloc_tmp_buffer_with_count): keep the order; allocate
an empty imemo first then xmalloc, to get rid of potential
memory leak when allocation imemo failed.
* parse.y (rb_parser_malloc, rb_parser_calloc, rb_parser_realloc):
ditto.
* process.c (rb_execarg_allocate_dup2_tmpbuf): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
imemo_alloc is used for three purposes: auto-free pointer (alternative
of alloca), alloc_tmp_buffer, and heap allocation for bison.
To make it clear, this change introduces three functions:
rb_imemo_alloc_auto_free_pointer,
rb_imemo_alloc_auto_free_maybe_mark_buffer, and
rb_imemo_alloc_parser_heap.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_imemo_alloc_new returns rb_imemo_alloc_t*, but took VALUEs, which is
inconsistent. To make the intention clear, it now takes only a pointer
to the buffer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Typical usages:
```
p ary[1..] # drop the first element; identical to ary[1..-1]
(1..).each {|n|...} # iterate forever from 1; identical to 1.step{...}
```
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (parser_dedent_string): stated that Ripper.dedent_string
is for internal use only.
[ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (no_digits): return tINTEGER instead of unexpected
end-of-input, to get rid of extra error messages.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: [DOC] fix return type in call-seq of Ripper.dedent_string,
clarify the method's behavior.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (bodystmt): expand opt_else to show the error message at
the right place.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (here_document): a continuing line is not the
terminator. [ruby-core:86283] [Bug #14621]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (tokadd_string): stop at continued line in dedented here
documents, to dedent for each lines before removing escaped
newlines. [ruby-core:86236] [Bug #14621]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (yycompile): in some cases (warning, error, dtrace,...),
ruby_sourcefile is expected to be NUL-terminated, so ensure it.
* template/prelude.c.tmpl (prelude_name): NUL-terminate to get rid
of copying static data.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (k_rescue, k_ensure): ignore indentations of `do`, it
is not at the beginning of line usually.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (f_kwrest): add the variable name as an argument, as
well as an internal variable.
* parse.y (new_args_tail): now keyword rest argument variable is
always placed between keyword arguments and block argument, so
so just reorder required and optional keyword arguments. no
longer kwrest duplicates.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: use tSP same as ripper instead of tSPACE.
[ruby-core:86080] [Bug #14597]
* ext/ripper/eventids2.c: tSP is defined in ripper.c now.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (heredoc_dedent): fix interpolated string literal dedent,
remove indentations from only nodes with the newline flag.
[ruby-core:85983] [Bug #14584]
* parse.y (here_document): set the newline flag on literal string
nodes starting at the beginning of line.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (tSPACE): define a separate token for escaped space, to
fix `redefining user token number of ' '` error at word list
separator on bison 2.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: named escaped whitespaces to show unexpected character.
bare whitespaces should not appear outside of word_list.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (assign_in_cond): refine a warning message for
assignment of a literal in conditinal expression.
[ruby-core:85872] [Bug #14562]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y (parser_yylex): as well as `tLBRACE_ARG` (expr block),
`tLBRACE` (primary block) also does not accept a label. only
hash brace accepts a label.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e