fix: allow file redirects at the end of a function

This will parse functions w/ a redirect as a function def rather than redirect statement w/ a function def inside of it
pull/504/merge
Amaan Qureshi 2023-08-21 19:35:31 +07:00
parent b3256b57d0
commit ed93d63542
2 changed files with 10 additions and 10 deletions

@ -289,7 +289,7 @@ module.exports = grammar({
optional(prec(1, ';;')), optional(prec(1, ';;')),
), ),
function_definition: $ => seq( function_definition: $ => prec.right(seq(
choice( choice(
seq( seq(
'function', 'function',
@ -308,7 +308,8 @@ module.exports = grammar({
$.subshell, $.subshell,
$.test_command), $.test_command),
), ),
), optional($.file_redirect),
)),
compound_statement: $ => seq( compound_statement: $ => seq(
'{', '{',

@ -986,14 +986,13 @@ do_nothing() { return 0 }
(word)) (word))
(word) (word)
(word))))) (word)))))
(redirected_statement (function_definition
(function_definition (word)
(word) (compound_statement
(compound_statement (command
(command (command_name
(command_name (word))
(word)) (word)))
(word))))
(file_redirect (file_redirect
(file_descriptor) (file_descriptor)
(number))) (number)))