summaryrefslogtreecommitdiff
path: root/test/ruby/test_keyword.rb
AgeCommit message (Collapse)Author
2018-01-19vm_insnhelper.c: fix many keyword argumentsnobu
* vm_insnhelper.c (vm_check_keyword): if the index exceeds the width of unspecified bits, that argument is specified. `unspecified_bits` still be a fixnum if the actual arguments do not exceed the limit, regardless the formal parameters size. [ruby-core:84921] [Bug #14373] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-19vm_insnhelper.c: should invert unspecified flagnobu
* vm_insnhelper.c (vm_check_keyword): invert unspecified value flag as `checkkeyword` result. fix up r58390. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-02compile.c: kw splat after splatnobu
* compile.c (setup_args): set keyword splat flag after splat arguments. [ruby-core:83638] [Bug #10856] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-10compile.c: fix KW_SPLAT flag conditionnobu
* compile.c (compile_array_keyword_arg): fix the condition of KW_SPLAT flag. splat is value node only without key node, simple assoc argument is not. [ruby-core:82291] [Bug #13793] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-10vm_args.c: prefer optarg to keyword splatnobu
* vm_args.c (setup_parameters_complex): prefer optional argument to splat keyword arguments for backward compatibility. [ruby-core:82280] [Bug #13791] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-08-05splat keyword hashnobu
* compile.c (compile_array_keyword_arg): set keyword splat flag if explicitly splatted. [ruby-core:68124] [Bug #10856] * vm_args.c (setup_parameters_complex): try keyword hash splat if given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-04vm_args.c: improve keyword argument errorsnobu
* vm_args.c (argument_arity_error): improve required keyword argument errors when non-keyword arguments given. [ruby-core:79439] [Bug #13196] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-01-18class.c: non-keyword hash classnobu
* class.c (rb_extract_keywords): keep the class of non-keyword elements hash as the original. [ruby-core:77813] [Bug #12884] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-08vm.c: check type of hash to mergenobu
* vm.c (core_hash_merge): check the type of the target hash to merge. [ruby-core:78536] [Bug #13015] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-12-04class.c: missing unknown_keyword_errornobu
* class.c (rb_get_kwargs): when values are stored, corresponding keys have been remove from the keyword hash, and the hash should be empty in that case. [ruby-dev:49893] [Bug #13004] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-29test_keyword.rb: more assertionsnobu
* test/ruby/test_keyword.rb (test_block_required_keyword): more assertions for positional and require keyword parameters. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-11-29test_keyword.rb: assert_raise_with_message valuenobu
* test/ruby/test_keyword.rb (test_block_required_keyword): assert_raise_with_message returns the raised exception object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16* vm_insnhelper.c (vm_call_method_each_type): should not set fastpathko1
with keyword arguments for VM_METHOD_TYPE_ATTRSET type methods. Normally, we can not use keyword arguments for this kind of methods, (obj.foo = 1), but we can set alias names for them. [Bug #11657] * test/ruby/test_keyword.rb: add a test for this fix. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53164 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-04-06* vm_args.c: protect value stack from calling other methodsko1
during complex parameter setting process (splat, kw, and so on). [Bug #11027] * vm_core.h: remove rb_thead_t::mark_stack_len. With this modification, we don't need to use th->mark_stack_len. * test/ruby/test_keyword.rb: add a test. * cont.c (cont_capture): catch up this fix. * vm.c (rb_thread_mark): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-01vm_args.c: fix non-symbol keys hashnobu
* vm_args.c (keyword_hash_p): fix non-symbol keys hash. rb_extract_keywords() returns 0 not Qnil when no symbol keys is included. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-12-28parse.y: fix internal IDs conflictnobu
* parse.y (f_kwrest, new_args_tail_gen): unnamed rest keyword and keywords bits arguments should be unique. since internal IDs depend on the local variable index in the current scope, new ID should be made before popping those vtables. [ruby-core:67157] [Bug #10659] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-27* vm_args.c: fix backtrace location for keyword related exceptions.ko1
For example, the following program def foo(k1: 1); end # line 1 foo(k2: 2) # line 2 causes "unknown keyword: k2 (ArgumentError)". Before this patch, the backtrace location is only line 2. However, error should be located at line 1 (over line 2 in stack trace). This patch fix this problem. * class.c (rb_keyword_error_new): separate exception creation logic from rb_keyword_error(), to use in vm_args.c. * vm_insnhelper.c (rb_arg_error_new): rename to rb_arity_error_new(). * vm_args.c (argument_arity_error): rename to argument_arity_error(). * vm_args.c (arugment_kw_error): added to fix backtrace. * test/ruby/test_keyword.rb: add tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13* test/lib/envutil.rb: Moved from test/ruby/.akr
* test/lib/find_executable.rb: Ditto. * test/lib/memory_status.rb: Ditto. * test/lib/test/unit.rb: require envutil. * test/: Don't require envutil in test files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-10-22class.c: delete expected keywords directlynobu
* class.c (unknown_keyword_error): delete expected keywords directly from raw table, so that the given block is not called. [ruby-core:65837] [Bug #10413] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-23parse.y: label cannot be followed by a modifiernobu
* parse.y (parse_ident): just after a label, new expression should start, cannot be a modifier. [ruby-core:65211] [Bug #10279] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-20compile.c: store IDs as Symbolsnobu
* compile.c (iseq_set_arguments): store local variable IDs in temporary list as Symbols. previously these are stored as Fixnums to prevent from GC, but IDs of dynamic symbols can exceed Fixnum range and cause RangeError at inverting from Fixnum. [ruby-dev:48564] [Bug #10266] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-10vm_insnhelper.c: fix implicit splat keyword argumentnobu
* vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack pointer to get rid of overwriting splat arguments by arguments for `to_hash` conversion. [ruby-core:63593] [Bug #10016] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-03vm.c: return the result hashnobu
* vm.c (core_hash_merge_kwd): should return the result hash, which may be converted from and differ from the given argument. [ruby-core:62921] [Bug #9898] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46342 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-26compile.c: non-destructive keyword splatnobu
* compile.c (compile_array_): make copy a first hash not to modify the argument itself. keyword splat should be non-destructive. [ruby-core:62161] [Bug #9776] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-25parse.y: required kwarg without parenthesesnobu
* parse.y (parser_yylex): only a newline after label should be significant. [ruby-core:61658] [Bug #9669] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45408 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-25parse.y: required kwarg without parenthesesnobu
* parse.y (lex_state_e, parser_params, f_arglist, parser_yylex): separate EXPR_LABELARG from EXPR_BEG and let newline significant, so that required keyword argument can place at the end of argument list without parentheses. [ruby-core:61658] [Bug #9669] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45405 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-25compile.c: unnamed keyword rest checknobu
* compile.c (iseq_set_arguments): set arg_keyword_check from nd_cflag, which is set by parser. internal ID is used for unnamed keyword rest argument, which should be separated from no keyword check. * iseq.c (rb_iseq_parameters): if no keyword check, keyword rest is present. * parse.y (new_args_tail_gen): set keywords check to nd_cflag, which equals to that keyword rest is not present. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44420 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-25test_keyword.rb: suppress warningsnobu
* test/ruby/test_keyword.rb (test_block_required_keyword): suppress shadowing outer variable warning. * test/ruby/test_keyword.rb (test_precedence_of_keyword_arguments): suppress unused variable warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-14vm_insnhelper.c: post arguments as mandatorynobu
* vm_insnhelper.c (vm_callee_setup_arg_complex): count post arguments as mandatory arguments. [ruby-core:57706] [Bug #8993] * vm_insnhelper.c (vm_yield_setup_block_args): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08class.c, vm_insnhelper.c: check unknown keywordsnobu
* class.c (rb_get_kwargs): if optional is negative, unknown keywords are allowed. * vm_insnhelper.c (vm_callee_setup_keyword_arg): check unknown keywords. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-08test_keyword.rb: check error messagesnobu
* test/ruby/test_keyword.rb (test_required_keyword): check also error messages. * test/ruby/test_keyword.rb (test_block_required_keyword): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-29* vm_insnhelper.c (vm_callee_setup_arg_complex, vm_yield_setup_block_args):ktsj
clear keyword arguments to prevent GC bug which occurs while marking VM stack. [ruby-dev:47729] [Bug #8964] * test/ruby/test_keyword.rb: tests for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-01compile.c: not simple if keyword argsnobu
* compile.c (iseq_set_arguments): not a simple single argument if any keyword arguments exist. [ruby-core:55203] [Bug #8463] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-01vm_insnhelper.c: extract keyword arguments after splatnobu
* vm_insnhelper.c (vm_yield_setup_block_args): split single parameter if any keyword arguments exist, and then extract keyword arguments. [ruby-core:55203] [Bug #8463] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-30* vm_insnhelper.c (vm_callee_setup_keyword_arg,mame
vm_callee_setup_arg_complex): consider a hash argument for keyword only when the number of arguments is more than the expected mandatory parameters. [ruby-core:53199] [ruby-trunk - Bug #8040] * test/ruby/test_keyword.rb: update a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-18compile.c: forward kwrestnobu
* compile.c (iseq_compile_each): forward anonymous and first keyword rest argument one. [ruby-core:55033] [Bug #8416]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-12vm_insnhelper.c: non-symbol keynobu
* vm_insnhelper.c (vm_callee_setup_keyword_arg): non-symbol key is not a keyword argument, keep it as an positional argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-04-09compile.c: append keyword hash to splatnobu
* compile.c (iseq_compile_each): append keyword hash to argument array to splat if needed. [ruby-core:54094] [Bug #8236] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-21vm_insnhelper.c: check required kwarg with resthashnobu
* vm_insnhelper.c (vm_callee_setup_keyword_arg): should check required keyword arguments even if rest hash is defined. [ruby-core:53608] [Bug #8139] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-12required keyword argumentsnobu
* compile.c (iseq_set_arguments, iseq_compile_each): support required keyword arguments. [ruby-core:51454] [Feature #7701] * iseq.c (rb_iseq_parameters): ditto. * parse.y (f_kw, f_block_kw): ditto. this syntax is still experimental, the notation may change. * vm_core.h (rb_iseq_struct): ditto. * vm_insnhelper.c (vm_callee_setup_keyword_arg): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-26test_keyword.rb: suppress warningnobu
* test/ruby/test_keyword.rb (TestKeywordArguments#m1): suppress argument prefix warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-26parse.y: keyword argument without parennobu
* parse.y (IS_LABEL_POSSIBLE): allow labels for keyword arguments just after method definition without a parenthesis. [ruby-core:52820] [Bug #7942] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-07parse.y: bare kwrest_marknobu
* parse.y (f_kwrest): allow bare kwrest_mark as valid syntax. its semantics is still undefined. [Bug #7662] [ruby-core:51269] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-01-07vm_insnhelper.c: keyrest should not overwrite rest argnobu
* vm_insnhelper.c (vm_callee_setup_arg_complex, vm_yield_setup_block_args): set keyrest hash after making rest array, so that the last element will not be overwritten. [ruby-core:51278] [Bug #7665] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-30* test/ruby/test_keyword.rb: add a test for passing hashktsj
as a last argument. [ruby-dev:46712] [Bug #7529] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-30* vm_insnhelper.c: set keyword hash on Proc/block calls.ktsj
[ruby-core:51172] [Bug #7630] * test/ruby/test_keyword.rb: add tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38657 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-12-11* iseq.c (rb_iseq_parameters): fix limit for optional arguments.eregon
* test/ruby/test_keyword.rb: tests for above. * vm_core.h (struct rb_iseq_struct): update documentation with keyword arguments. [Bug #7540] [ruby-core:50735] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-26* vm_core.h (struct rb_iseq_struct), compile.c (iseq_set_arguments), iseq.c ↵mame
(rb_iseq_parameters), vm_insnhelper.c (vm_callee_setup_arg_complex): support Method#parameters for keyword arguments. The provisional spec is what Benoit Daloze proposed. [ruby-core:40518] * test/ruby/test_keyword.rb: add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-26* vm_core.h (struct rb_iseq_struct), compile.c (iseq_set_arguments, ↵mame
iseq_compile_each), vm_insnhelper.c (vm_callee_setup_arg_complex): implement keyword arguments. See [ruby-core:40290] The feature is promised to be included in 2.0, but the detail spec is still under discussion; this commit is a springboard for further discussion. Please try it and give us feedback. This commit includes fixes for some problems reported by Benoit Daloze <eregontp AT gmail.com> [ruby-core:40518] and Marc-Andre Lafortune <ruby-core-mailing-list AT marc-andre.ca> [ruby-core:41772]. * iseq.c (iseq_free, prepare_iseq_build): bookkeeping. * test/ruby/test_keyword.rb: add tests for keyword arguments. * test/ripper/dummyparser.rb (class DummyParser): temporal fix for ripper test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e