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

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