Commit Graph

2875 Commits

Author SHA1 Message Date
Tatsuhiko Kubo 5fac7a73cb Use mrb_exc_new_str_lit(). 2015-01-03 23:34:13 +09:00
Tatsuhiko Kubo 093560e7d1 Use suitable type. 2014-12-27 10:18:18 +09:00
Kouhei Sutou 5ec676aa37 Fix splat and multiple assignments
Case1: From variable

Code:

    a = [1, 2, 3, 4, 5]
    b, c, *d = a

    p [a, b, c, d]

Before:

    [[1, 2, 3, 4, 5], 1, 2, []]

After:

    [[1, 2, 3, 4, 5], 1, 2, [3, 4, 5]]

Ruby:

    [[1, 2, 3, 4, 5], 1, 2, [3, 4, 5]]

Case2: From variables

Code:

    a = [1, 2, 3]
    b = [4, 5, 6, 7]
    c, d, *e, f, g = *a, *b

    p [a, b, c, d, e, f, g]

Before:

    [[1, 2, 3], [4, 5, 6, 7], 1, 2, [], 6, 7]

After:

    [[1, 2, 3], [4, 5, 6, 7], 1, 2, [3, 4, 5], 6, 7]

Ruby:

    [[1, 2, 3], [4, 5, 6, 7], 1, 2, [3, 4, 5], 6, 7]

Case 3: "for"

Code:

    a = [1, 2, 3, 4, 5, 6, 7]
    for b, c, *d, e, f in [a] do
      p [a, b, c, d, e, f]
    end

Before:

    [[1, 2, 3, 4, 5, 6, 7], 1, 2, [], nil, nil]

After:

    [[1, 2, 3, 4, 5, 6, 7], 1, 2, [3, 4, 5], 6, 7]

Ruby:

    [[1, 2, 3, 4, 5, 6, 7], 1, 2, [3, 4, 5], 6, 7]
2014-12-23 21:16:01 +09:00
Yukihiro "Matz" Matsumoto 358dd61107 block_given? should return correct value when called in blocks; close #2678
avoid a loop to find parent's callinfo using mrb->c->cibase[env->cioff]
2014-12-19 19:05:27 +09:00
Yukihiro "Matz" Matsumoto 5014bfb50d block_given? should return false on top-level; ref #2678 2014-12-19 18:51:14 +09:00
Yukihiro "Matz" Matsumoto 2732879f3e String#[]: float handling merged to #2677 2014-12-17 20:19:52 +09:00
Yukihiro "Matz" Matsumoto 4319eaaa45 try to convert not only nil but every objects to fixnums; ref #2677 2014-12-17 20:08:26 +09:00
h2so5 05b00a14c5 String#[] should reject nil index 2014-12-17 14:01:39 +09:00
Yukihiro "Matz" Matsumoto a19a6edb7c mrb_str_new(mrb, "", len) creates an unmodifiable string object; ref #2674 2014-12-17 08:06:44 +09:00
sdottaka fe01ce5b02 Fix crash if #inspect does not return a string value
case 1
~~~
class A; def inspect; 1; end; end
A.new.a
~~~

case 2

~~~
class A
  def self.inspect
    1
  end
  alias_method :a, :b
end
~~~
2014-12-12 23:05:22 +09:00
Yukihiro "Matz" Matsumoto 4078670bca mrb_p() should print mrb_obj_as_string() if #inspect does not return a string value 2014-12-12 21:32:02 +09:00
Yukihiro "Matz" Matsumoto 44c29e88ae block_given did not work with nested block invocation for some cases; fix #2665 2014-12-11 00:36:18 +09:00
Yukihiro "Matz" Matsumoto 4eff93632f mrb_parser_dump() did not work with block arguments 2014-12-11 00:08:56 +09:00
Yukihiro "Matz" Matsumoto 4c70b5c644 should not pop register when value from multiple assignment required 2014-12-01 08:06:23 +09:00
Yukihiro "Matz" Matsumoto 09c6ca936c preserve ICLASS in ci->target_class; fix #2657; ensuring #1467 #1470 #1493 still works 2014-11-28 20:35:06 +09:00
Yukihiro "Matz" Matsumoto e4ca706530 wrong register adjustment 2014-11-27 16:21:15 +09:00
Yukihiro "Matz" Matsumoto e1a7fa925e add "fall through" comment 2014-11-26 01:03:57 +09:00
Robert Mosolgo 0133d9ac70 fix(String) String#[] accepts float; close #2650 #2651 2014-11-26 01:03:38 +09:00
Yukihiro "Matz" Matsumoto 28bd33297a wrong register number adjustment in multiple assignment; fix #2654 2014-11-26 00:43:39 +09:00
Yukihiro "Matz" Matsumoto c424892c5e OP_APOST local variable display was wrong 2014-11-26 00:43:39 +09:00
cremno 94f1ad6cc1 remove unnecessary _WIN32 preprocessor check
SIZE_MAX < UINT32_MAX is false on Win32 / Win64.
2014-11-25 02:04:30 +01:00
Yukihiro "Matz" Matsumoto 9ec00ef182 align indent of local variable names in codedump() 2014-11-23 07:36:58 +09:00
Yukihiro "Matz" Matsumoto bce75e2746 should support recursive mlhs decomposition, e.g. (a,b),c = [1,2],3 2014-11-22 12:16:59 +09:00
sdottaka 820f6d147f Fix an error when calling a method implemented in C by super() with arguments. This fix makes the following code workable:
Expected:

class MRBTime < Time; def self.new; super(2012, 4, 21); end; end
MRBTime.new # => Sat Apr 21 00:00:00 2012

Actual:

class MRBTime < Time; def self.new; super(2012, 4, 21); end; end
MRBTime.new # => can't convert nil into Integer (TypeError)
2014-11-19 13:29:22 +09:00
Yukihiro "Matz" Matsumoto 5c6d6309b6 separate mrb_notimplement() and mrb_notimplement_m(); ref #2636 2014-11-19 01:03:19 +09:00
Robert Mosolgo 8dc4d9d973 fix mrb_notimplement typo 2014-11-17 12:13:19 -08:00
ksss 9a06cfa9d8 Implement C API mrb_notimplement 2014-11-17 17:42:20 +09:00
Yukihiro "Matz" Matsumoto 70c9866751 add Float::{INFINITY,NAN} if available 2014-11-12 15:46:31 +09:00
Hiroshi Mimaki c29185ff13 %zu format is not supported by MSVC 2014-11-06 13:30:42 +09:00
Yukihiro "Matz" Matsumoto 8a6e600562 avoid using rewind(3) to load mrb files 2014-11-04 14:05:36 +09:00
Yukihiro "Matz" Matsumoto 0e2ab2210c read whole mrb file at once to calculate correct padding offset; ref #2630 2014-11-04 10:12:46 +09:00
Yukihiro "Matz" Matsumoto 0e40468809 specify alignment specifier for GCC and MSC; ref #2630 2014-11-04 07:10:41 +09:00
Yukihiro "Matz" Matsumoto be844f9284 Fix misaligned access when reading irep; close #2630
Add padding bytes before iseq block that may be used as mrb_code[].
Note that dumped mrb format has changed.

Based on a patch from kimu_shu <alfvegardrisc@gmail.com>
2014-11-04 02:41:42 +09:00
Yukihiro "Matz" Matsumoto 378aa8a9c8 avoid wrong ArgumentError from mrb_get_args() when surrounding method takes more than one argument; ref #2627 2014-10-30 10:31:06 +09:00
Yukihiro "Matz" Matsumoto 5bd3d9bc27 add cast to return from aget_index(); ref #2627 2014-10-30 10:27:05 +09:00
mattn eaa0296fc5 Handle Array#[float, int] Close #2626 2014-10-29 19:27:20 +09:00
Jun Hiroe 5235e54137 Fix mrb_convert_to_integer. 2014-10-29 01:30:30 +09:00
Jun Hiroe ad77ed8bf3 Refactor for_body func 2014-10-28 23:31:25 +09:00
Yukihiro "Matz" Matsumoto f4260a851a Merge pull request #2623 from suzukaze/fix-indent
Fix indent
2014-10-28 23:26:48 +09:00
Yukihiro "Matz" Matsumoto 5347fb923d Merge pull request #2621 from suzukaze/fix-parse_string
Replace int with mrb_bool in parse_string func
2014-10-28 23:26:23 +09:00
Jun Hiroe ec7dbee4b1 Fix indent 2014-10-28 01:52:50 +09:00
Jun Hiroe 832b529679 Replace int with mrb_bool in parse_string func 2014-10-28 00:11:34 +09:00
Jun Hiroe 9ca1745833 Replace int with mrb_bool in local_var_p func 2014-10-28 00:11:16 +09:00
Jun Hiroe 34175bf41f Refactor yylex func 2014-10-27 01:27:00 +09:00
Jun Hiroe 7bd2a8508e Refactor mrbc_context_new func 2014-10-27 00:29:00 +09:00
Yukihiro "Matz" Matsumoto 69ba4f0ed5 instance_methods etc should not include undef'ed method names; based on a patch from @cremno; fix #2613 2014-10-20 11:11:26 +09:00
Jan Berdajs aff2be4b40 fix typo (i->idx) 2014-10-15 14:11:00 +02:00
Hiroyuki Matsuzaki e77ea4e5f2 fixed. cygwin-gcc(ver4.8.3) warning in conv_digit() 2014-10-02 19:50:58 +09:00
Yukihiro "Matz" Matsumoto 83992ee163 cast MRB_ENV_STACK_LEN to (mrb_int); ref #2600 2014-10-02 17:59:01 +09:00
Hiroshi Mimaki ed15477c74 Pacify MSVC warnings for numeric.c, proc.c, and symbol.c 2014-10-02 13:37:49 +09:00