Commit 66f64d4e authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #3303 from bouk/empty-nil

Interpret argument in 'f ()' as nil instead of nothing
parents 246a9a8a 523c2670
...@@ -10,3 +10,12 @@ assert('Compiling multiple files without new line in last line. #2361') do ...@@ -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 "#{cmd('mrbc')}:#{a.path}:Syntax OK", result.chomp
assert_equal 0, $?.exitstatus assert_equal 0, $?.exitstatus
end 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
...@@ -2109,7 +2109,7 @@ primary : literal ...@@ -2109,7 +2109,7 @@ primary : literal
} }
| tLPAREN_ARG {p->lstate = EXPR_ENDARG;} rparen | tLPAREN_ARG {p->lstate = EXPR_ENDARG;} rparen
{ {
$$ = 0; $$ = new_nil(p);
} }
| tLPAREN compstmt ')' | tLPAREN compstmt ')'
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment