diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2016-11-30 02:52:39 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-11-30 02:52:39 +0900 |
| commit | 66f64d4ee8a439794a15981946d271ef602fbfe7 (patch) | |
| tree | 517b0273a17f9d222dc74954cb6152eeeef78b8f | |
| parent | 246a9a8acd4e45a184ffd11bdd92a5b7736bf1cd (diff) | |
| parent | 523c267020787c3545bd72f27362cf8727372c0d (diff) | |
| download | mruby-66f64d4ee8a439794a15981946d271ef602fbfe7.tar.gz mruby-66f64d4ee8a439794a15981946d271ef602fbfe7.zip | |
Merge pull request #3303 from bouk/empty-nil
Interpret argument in 'f ()' as nil instead of nothing
| -rw-r--r-- | mrbgems/mruby-compiler/bintest/mrbc.rb | 9 | ||||
| -rw-r--r-- | mrbgems/mruby-compiler/core/parse.y | 2 |
2 files changed, 10 insertions, 1 deletions
diff --git a/mrbgems/mruby-compiler/bintest/mrbc.rb b/mrbgems/mruby-compiler/bintest/mrbc.rb index e4dc6a9a8..e27365edb 100644 --- a/mrbgems/mruby-compiler/bintest/mrbc.rb +++ b/mrbgems/mruby-compiler/bintest/mrbc.rb @@ -10,3 +10,12 @@ assert('Compiling multiple files without new line in last line. #2361') do assert_equal "#{cmd('mrbc')}:#{a.path}:Syntax OK", result.chomp assert_equal 0, $?.exitstatus end + +assert('parsing function with void argument') do + a, out = Tempfile.new('a.rb'), Tempfile.new('out.mrb') + a.write('f ()') + a.flush + result = `#{cmd('mrbc')} -c -o #{out.path} #{a.path} 2>&1` + assert_equal "#{cmd('mrbc')}:#{a.path}:Syntax OK", result.chomp + assert_equal 0, $?.exitstatus +end diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 3a14b4fcc..9f6914104 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -2109,7 +2109,7 @@ primary : literal } | tLPAREN_ARG {p->lstate = EXPR_ENDARG;} rparen { - $$ = 0; + $$ = new_nil(p); } | tLPAREN compstmt ')' { |
