diff options
| -rw-r--r-- | include/mruby/proc.h | 2 | ||||
| -rw-r--r-- | src/class.c | 4 | ||||
| -rw-r--r-- | src/codegen.c | 1 | ||||
| -rw-r--r-- | src/hash.c | 4 | ||||
| -rw-r--r-- | src/string.c | 4 | ||||
| -rw-r--r-- | src/variable.c | 2 | ||||
| -rw-r--r-- | test/t/syntax.rb | 11 | ||||
| -rw-r--r-- | tools/mirb/mirb.c | 8 |
8 files changed, 23 insertions, 13 deletions
diff --git a/include/mruby/proc.h b/include/mruby/proc.h index 50e55f231..96f7ddbd7 100644 --- a/include/mruby/proc.h +++ b/include/mruby/proc.h @@ -52,7 +52,7 @@ struct RProc *mrb_closure_new(mrb_state*, mrb_irep*); void mrb_proc_copy(struct RProc *a, struct RProc *b); #include "mruby/khash.h" -KHASH_DECLARE(mt, mrb_sym, struct RProc*, 1); +KHASH_DECLARE(mt, mrb_sym, struct RProc*, 1) #if defined(__cplusplus) } /* extern "C" { */ diff --git a/src/class.c b/src/class.c index a5b028105..618a6d1f6 100644 --- a/src/class.c +++ b/src/class.c @@ -15,7 +15,7 @@ #include "mruby/array.h" #include "error.h" -KHASH_DEFINE(mt, mrb_sym, struct RProc*, 1, kh_int_hash_func, kh_int_hash_equal); +KHASH_DEFINE(mt, mrb_sym, struct RProc*, 1, kh_int_hash_func, kh_int_hash_equal) typedef struct fc_result { mrb_sym name; @@ -630,7 +630,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...) } break; default: - mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalide argument specifier %c", c); + mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalid argument specifier %c", c); break; } } diff --git a/src/codegen.c b/src/codegen.c index fd41e3cb8..1e468867c 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -1412,7 +1412,6 @@ codegen(codegen_scope *s, node *tree, int val) codegen(s, tree->cdr->cdr->car, VAL); pop(); gen_assignment(s, tree->car, cursp(), val); - if (val) pop(); dispatch(s, pos); break; } diff --git a/src/hash.c b/src/hash.c index c74ac837b..c7a419250 100644 --- a/src/hash.c +++ b/src/hash.c @@ -29,8 +29,8 @@ mrb_hash_ht_hash_equal(mrb_state *mrb, mrb_value a, mrb_value b) return mrb_eql(mrb, a, b); } -KHASH_DECLARE(ht, mrb_value, mrb_value, 1); -KHASH_DEFINE (ht, mrb_value, mrb_value, 1, mrb_hash_ht_hash_func, mrb_hash_ht_hash_equal); +KHASH_DECLARE(ht, mrb_value, mrb_value, 1) +KHASH_DEFINE (ht, mrb_value, mrb_value, 1, mrb_hash_ht_hash_func, mrb_hash_ht_hash_equal) static void mrb_hash_modify(mrb_state *mrb, mrb_value hash); diff --git a/src/string.c b/src/string.c index 425b79ca7..7ab6e5806 100644 --- a/src/string.c +++ b/src/string.c @@ -2511,7 +2511,7 @@ mrb_cstr_to_inum(mrb_state *mrb, const char *str, int base, int badcheck) return mrb_fixnum_value(result); } bad: - mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalide string for number(%s)", str); + mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalid string for number(%s)", str); /* not reached */ return mrb_fixnum_value(0); } @@ -2621,7 +2621,7 @@ mrb_cstr_to_dbl(mrb_state *mrb, const char * p, int badcheck) if (p == end) { if (badcheck) { bad: - mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalide string for float(%s)", p); + mrb_raisef(mrb, E_ARGUMENT_ERROR, "invalid string for float(%s)", p); /* not reached */ } return d; diff --git a/src/variable.c b/src/variable.c index 7d583da40..6907a8e2a 100644 --- a/src/variable.c +++ b/src/variable.c @@ -256,7 +256,7 @@ iv_free(mrb_state *mrb, iv_tbl *t) #endif KHASH_DECLARE(iv, mrb_sym, mrb_value, 1) -KHASH_DEFINE(iv, mrb_sym, mrb_value, 1, kh_int_hash_func, kh_int_hash_equal); +KHASH_DEFINE(iv, mrb_sym, mrb_value, 1, kh_int_hash_func, kh_int_hash_equal) typedef struct iv_tbl { khash_t(iv) h; diff --git a/test/t/syntax.rb b/test/t/syntax.rb index 47221d425..0501608e5 100644 --- a/test/t/syntax.rb +++ b/test/t/syntax.rb @@ -58,3 +58,14 @@ assert('Nested const reference') do Syntax4Const::CONST1 == "hello world" and Syntax4Const::Const2.new.const1 == "hello world" end + +assert('Abbreviated variable assignment as returns') do + module Syntax4AbbrVarAsgnAsReturns + class A + def b + @c ||= 1 + end + end + end + Syntax4AbbrVarAsgnAsReturns::A.new.b == 1 +end diff --git a/tools/mirb/mirb.c b/tools/mirb/mirb.c index 502400c72..d3903ef57 100644 --- a/tools/mirb/mirb.c +++ b/tools/mirb/mirb.c @@ -5,7 +5,7 @@ ** an interactive way and executes it ** immediately. It's a REPL... */ - + #include <string.h> #include <mruby.h> @@ -143,7 +143,7 @@ print_cmdline(int code_block_open) int main(void) { - char last_char; + int last_char; char ruby_code[1024] = { 0 }; char last_code_line[1024] = { 0 }; int char_index; @@ -156,7 +156,7 @@ main(void) print_hint(); - /* new interpreter instance */ + /* new interpreter instance */ mrb = mrb_open(); if (mrb == NULL) { fprintf(stderr, "Invalid mrb interpreter, exiting mirb"); @@ -207,7 +207,7 @@ main(void) parser->send = ruby_code + strlen(ruby_code); parser->lineno = 1; mrb_parser_parse(parser, cxt); - code_block_open = is_code_block_open(parser); + code_block_open = is_code_block_open(parser); if (code_block_open) { /* no evaluation of code */ |
