aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_keyword.rb
Commit message (Collapse)AuthorAgeFilesLines
* compile.c: kw splat after splatnobu2017-11-021-0/+6
| | | | | | | * 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
* compile.c: fix KW_SPLAT flag conditionnobu2017-08-101-0/+2
| | | | | | | | * 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
* vm_args.c: prefer optarg to keyword splatnobu2017-08-101-0/+4
| | | | | | | | * 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
* splat keyword hashnobu2017-08-051-0/+11
| | | | | | | | | | * 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
* vm_args.c: improve keyword argument errorsnobu2017-07-041-0/+13
| | | | | | | | * 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
* class.c: non-keyword hash classnobu2017-01-181-0/+12
| | | | | | | * 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
* vm.c: check type of hash to mergenobu2016-12-081-0/+20
| | | | | | | * 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
* class.c: missing unknown_keyword_errornobu2016-12-041-0/+7
| | | | | | | | * 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
* test_keyword.rb: more assertionsnobu2016-11-291-0/+9
| | | | | | | * 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
* test_keyword.rb: assert_raise_with_message valuenobu2016-11-291-6/+2
| | | | | | | * 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
* * vm_insnhelper.c (vm_call_method_each_type): should not set fastpathko12015-12-161-0/+20
| | | | | | | | | | | | | | | 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
* Add frozen_string_literal: false for all filesnaruse2015-12-161-0/+1
| | | | | | 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
* * vm_args.c: protect value stack from calling other methodsko12015-04-061-0/+10
| | | | | | | | | | | | | | 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
* vm_args.c: fix non-symbol keys hashnobu2015-01-011-0/+7
| | | | | | | | * 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
* parse.y: fix internal IDs conflictnobu2014-12-281-0/+20
| | | | | | | | | | * 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
* * vm_args.c: fix backtrace location for keyword related exceptions.ko12014-11-271-2/+13
| | | | | | | | | | | | | | | | | | | | 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
* * test/lib/envutil.rb: Moved from test/ruby/.akr2014-11-131-1/+0
| | | | | | | | | | | | | | * 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
* class.c: delete expected keywords directlynobu2014-10-221-0/+15
| | | | | | | | * 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
* parse.y: label cannot be followed by a modifiernobu2014-09-231-0/+14
| | | | | | | * 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
* compile.c: store IDs as Symbolsnobu2014-09-201-0/+9
| | | | | | | | | | * 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
* vm_insnhelper.c: fix implicit splat keyword argumentnobu2014-07-101-0/+10
| | | | | | | | * 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
* vm.c: return the result hashnobu2014-06-031-0/+11
| | | | | | | | * 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
* compile.c: non-destructive keyword splatnobu2014-04-261-0/+13
| | | | | | | | * 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
* parse.y: required kwarg without parenthesesnobu2014-03-251-0/+9
| | | | | | | * 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
* parse.y: required kwarg without parenthesesnobu2014-03-251-0/+10
| | | | | | | | | * 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
* compile.c: unnamed keyword rest checknobu2013-12-251-0/+9
| | | | | | | | | | | | | * 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
* test_keyword.rb: suppress warningsnobu2013-12-251-4/+4
| | | | | | | | | | * 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
* vm_insnhelper.c: post arguments as mandatorynobu2013-12-141-0/+10
| | | | | | | | * 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
* class.c, vm_insnhelper.c: check unknown keywordsnobu2013-12-081-0/+2
| | | | | | | | | * 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
* test_keyword.rb: check error messagesnobu2013-12-081-6/+8
| | | | | | | | | * 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
* * vm_insnhelper.c (vm_callee_setup_arg_complex, vm_yield_setup_block_args):ktsj2013-09-291-0/+19
| | | | | | | | | | 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
* compile.c: not simple if keyword argsnobu2013-06-011-0/+2
| | | | | | | * 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
* vm_insnhelper.c: extract keyword arguments after splatnobu2013-06-011-1/+6
| | | | | | | | * 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
* * vm_insnhelper.c (vm_callee_setup_keyword_arg,mame2013-05-301-1/+11
| | | | | | | | | | 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
* compile.c: forward kwrestnobu2013-05-181-0/+30
| | | | | | | * 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
* vm_insnhelper.c: non-symbol keynobu2013-04-121-0/+1
| | | | | | | * 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
* compile.c: append keyword hash to splatnobu2013-04-091-0/+21
| | | | | | | | * 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
* vm_insnhelper.c: check required kwarg with resthashnobu2013-03-211-0/+16
| | | | | | | | * 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
* required keyword argumentsnobu2013-03-121-0/+21
| | | | | | | | | | | | * 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
* test_keyword.rb: suppress warningnobu2013-02-261-1/+1
| | | | | | | * 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
* parse.y: keyword argument without parennobu2013-02-261-0/+16
| | | | | | | | | * 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
* parse.y: bare kwrest_marknobu2013-01-071-0/+8
| | | | | | | * 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
* vm_insnhelper.c: keyrest should not overwrite rest argnobu2013-01-071-0/+11
| | | | | | | | * 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
* * test/ruby/test_keyword.rb: add a test for passing hashktsj2012-12-301-0/+1
| | | | | | 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
* * vm_insnhelper.c: set keyword hash on Proc/block calls.ktsj2012-12-301-0/+119
| | | | | | | | [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
* * iseq.c (rb_iseq_parameters): fix limit for optional arguments.eregon2012-12-111-0/+24
| | | | | | | | * 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
* * vm_core.h (struct rb_iseq_struct), compile.c (iseq_set_arguments), iseq.c ↵mame2011-12-261-0/+9
| | | | | | | | (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
* * vm_core.h (struct rb_iseq_struct), compile.c (iseq_set_arguments, ↵mame2011-12-261-0/+105
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