*** Running test-arglist ===== CASE: -n -c json write () ===== json write () ^ [ -c flag ]:1: Empty arg list not allowed ===== CASE: -n -c p (; n=42) ===== (command.Simple blame_tok:

more_env: [] words: [{

}] redirects: [] typed_args: (ArgList left: pos_args: [] semi_tok: named_args: [(NamedArg name: value:(expr.Const c:))] right: ) do_fork: T ) ===== CASE: -n -c = f(; n=42) ===== (command.Expr keyword: e: (Eggex left: regex: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:)) flags: [] canonical_flags: "" ) ) ===== CASE: -n -c = / < capture d+ as date > / ===== (command.Expr keyword: / ===== (command.Expr keyword: e: (Eggex left: regex: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:)) flags: [(EggexFlag negated:F flag:)] canonical_flags: i ) ) ===== CASE: -n -c = / d+ ; !i / ===== = / d+ ; !i / ^ [ -c flag ]:1: Flag can't be negated ===== CASE: -n -c = / d+ ; reg_oops / ===== = / d+ ; reg_oops / ^~~~~~~~ [ -c flag ]:1: Invalid regex flag 'reg_oops' ===== CASE: -n -c = / d+ ; !i; PCRE / ===== (command.Expr keyword: e: (Eggex left: regex: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:)) flags: [(EggexFlag negated:F flag:)] trans_pref: ) ) ===== CASE: -n -c = / d+ ; i reg_newline ; ERE / ===== (command.Expr keyword: e: (Eggex left: regex: (re.Repeat child:(PerlClass name:d) op:(re_repeat.Op op:)) flags: [] trans_pref: canonical_flags: "" ) ) ===== CASE: -n -c = / d+ ; / ===== (command.Expr keyword: trim() ===== (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (expr.FuncCall func: (Attribute obj: (expr.Var name:) op: "> attr: ctx: expr_context.Store ) args: (ArgList left: pos_args:[] named_args:[] right:) ) ) ===== CASE: -n -c func f(x Int) => List[Int] { echo hi } ===== (Func keyword: name: positional: (ParamGroup params: [ (Param blame_tok: name: x type: (TypeExpr tok: name:Int) ) ] ) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) ) OK test-fat-arrow *** Running test-float-literals ===== CASE: -n -c = 42.0 ===== (command.Expr keyword: e:(expr.Const c:)) ===== CASE: -n -c = 42_.0 ===== = 42_.0 ^ [ -c flag ]:1: Syntax error in expression (near Id.Expr_DecInt) ===== CASE: -n -c = 42. ===== = 42. ^ [ -c flag ]:1: Syntax error in expression (near Id.Eof_Real) ===== CASE: -n -c = .333 ===== = .333 ^ [ -c flag ]:1: Syntax error in expression (near Id.Expr_Dot) ===== CASE: -n -c = _42.0 ===== = _42.0 ^ [ -c flag ]:1: Syntax error in expression (near Id.Expr_DecInt) OK test-float-literals *** Running test-for-parse-bare-word ===== CASE: -n -c for x in bare { echo $x } ===== for x in bare { ^~~~ [ -c flag ]:2: Surround this word with either parens or quotes (parse_bare_word) ===== CASE: -n -c for x in a b { echo $x } ===== (command.ForEach keyword: iter_names: [x] iterable: (for_iter.Words words:[{} {}]) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) ] redirects: [] right: ) redirects: [] ) ===== CASE: -n -c for x in *.py { echo $x } ===== (command.ForEach keyword: iter_names: [x] iterable: (for_iter.Words words:[{ <.py>}]) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) ] redirects: [] right: ) redirects: [] ) ===== CASE: -n -c for x in "quoted" { echo $x } ===== (command.ForEach keyword: iter_names: [x] iterable: (for_iter.Words words:[{(DQ )}]) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) ] redirects: [] right: ) redirects: [] ) OK test-for-parse-bare-word *** Running test-func-def ===== CASE: -n -c func f(p) { var p = foo } ===== func f(p) { var p = foo } ^ [ -c flag ]:1: 'p' was already declared ===== CASE: -n -c func f(p; n) { var n = foo } ===== func f(p; n) { var n = foo } ^ [ -c flag ]:1: 'n' was already declared OK test-func-def *** Running test-func-sig ===== CASE: -n -c func f { echo hi } ===== func f { echo hi } ^ [ -c flag ]:1: Syntax error in expression (near Id.Op_LBrace) ===== CASE: -n -c func f () { echo hi } ===== (Func keyword: name: body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) ) ===== CASE: -n -c func f (a List[Int] = [3,4]) { echo hi } ===== (Func keyword: name: positional: (ParamGroup params: [ (Param blame_tok: name: a type: (TypeExpr tok: name: List params: [(TypeExpr tok: name:Int)] ) default_val: (expr.List left: elts: [(expr.Const c:) (expr.Const c:)] ctx: expr_context.Store ) ) ] ) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) ) ===== CASE: -n -c func f (a, b, ...rest; c) { echo hi } ===== (Func keyword: name: positional: (ParamGroup params: [(Param blame_tok: name:a) (Param blame_tok: name:b)] rest_of: (RestParam blame_tok: name:rest) ) named: (ParamGroup params:[(Param blame_tok: name:c)]) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) ) ===== CASE: -n -c func f (a, b, ...rest; c, ...named) { echo hi } ===== (Func keyword: name: positional: (ParamGroup params: [(Param blame_tok: name:a) (Param blame_tok: name:b)] rest_of: (RestParam blame_tok: name:rest) ) named: (ParamGroup params: [(Param blame_tok: name:c)] rest_of: (RestParam blame_tok: name:named) ) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) ) ===== CASE: -n -c func f (a, b, ...rest; c, ...named;) { echo hi } ===== func f (a, b, ...rest; c, ...named;) { echo hi } ^ [ -c flag ]:1: Syntax error in expression (near Id.Op_Semi) OK test-func-sig *** Running test-func-var-checker ===== CASE: -n -c func f(x) { setvar x = True } ===== (Func keyword: name: positional: (ParamGroup params:[(Param blame_tok: name:x)]) body: (BraceGroup left: children: [ (command.Mutation keyword: lhs: [(y_lhs.Var name:)] op: rhs: (expr.Var name:) ) ] redirects: [] right: ) ) ===== CASE: -n -c func f() { setvar x = True } ===== setvar x = True ^ [ -c flag ]:3: setvar couldn't find matching 'var x' OK test-func-var-checker *** Running test-hay-assign ===== CASE: -n -c name = val ===== name = val ^ [ -c flag ]:2: Unexpected = (Hint: use var/setvar, or quote it) ===== CASE: -n -c rule { x = 42 } ===== x = 42 ^ [ -c flag ]:3: Unexpected = (Hint: use var/setvar, or quote it) ===== CASE: -n -c RULE { x = 42 } ===== x = 42 ^ [ -c flag ]:3: Unexpected = (Hint: use var/setvar, or quote it) ===== CASE: -n -c Rule { x = 42 } ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] block: (LiteralBlock brace_group: (BraceGroup left: children: [(command.VarDecl lhs:[(NameType name:)] rhs:(expr.Const c:))] redirects: [] right: ) lines: [ (SourceLine line_num:2 content:"Rule {\n" src:(source__CFlag)) (SourceLine line_num:3 content:" x = 42\n" src:...0x7f58a2e30f50) (SourceLine line_num:4 content:"}\n" src:...0x7f58a2e30f50) ] ) do_fork: T ) ===== CASE: -n -c Rule X Y { x = 42 } ===== (command.Simple blame_tok: more_env: [] words: [{} {} {}] redirects: [] block: (LiteralBlock brace_group: (BraceGroup left: children: [(command.VarDecl lhs:[(NameType name:)] rhs:(expr.Const c:))] redirects: [] right: ) lines: [ (SourceLine line_num:2 content:"Rule X Y {\n" src:(source__CFlag)) (SourceLine line_num:3 content:" x = 42\n" src:...0x7ff17824ef50) (SourceLine line_num:4 content:"}\n" src:...0x7ff17824ef50) ] ) do_fork: T ) ===== CASE: -n -c RULe { # inconsistent but OK x = 42 } ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] block: (LiteralBlock brace_group: (BraceGroup left: children: [(command.VarDecl lhs:[(NameType name:)] rhs:(expr.Const c:))] redirects: [] right: ) lines: [ (SourceLine line_num:2 content:"RULe { # inconsistent but OK\n" src:(source__CFlag)) (SourceLine line_num:3 content:" x = 42\n" src:...0x7fa764713f10) (SourceLine line_num:4 content:"}\n" src:...0x7fa764713f10) ] ) do_fork: T ) ===== CASE: -n -c hay eval :result { Rule { foo = 42 } bar = 43 # parse error here } ===== bar = 43 # parse error here ^ [ -c flag ]:8: Unexpected = (Hint: use var/setvar, or quote it) ===== CASE: -n -c hay define TASK TASK build { foo = 42 } ===== foo = 42 ^ [ -c flag ]:5: Unexpected = (Hint: use var/setvar, or quote it) ===== CASE: -n -c hay define Package/TASK Package libc { TASK build { # this is not an attribute, should not be valid foo = 42 } } ===== foo = 42 ^ [ -c flag ]:7: Unexpected = (Hint: use var/setvar, or quote it) ===== CASE: -n -c hay define Rule Rule { return (x) } ===== return (x) ^ [ -c flag ]:5: Typed return is only allowed inside func OK test-hay-assign *** Running test-hay-shell-assign ===== CASE: -n -c hay define Package Package foo { version=1 } ===== version=1 ^~~~~~~~ [ -c flag ]:5: Use var/setvar to assign in YSH ===== CASE: -n -c hay define Package/User Package foo { User bob { sudo=1 } } ===== sudo=1 ^~~~~ [ -c flag ]:6: Use var/setvar to assign in YSH ===== CASE: -n -c hay define Package/SHELL/User Package foo { SHELL bob { sudo=1 User { name = "z" } } } ===== (command.CommandList children: [ (command.Simple blame_tok: more_env: [] words: [{} {} {}] redirects: [] do_fork: T ) (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] block: (LiteralBlock brace_group: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] block: (LiteralBlock brace_group: (BraceGroup left: children: [ (command.ShAssignment left: children: [ (command.VarDecl lhs: [(NameType name:)] rhs: (DQ ) ) ] redirects: [] right: ) lines: [ (SourceLine line_num: 7 content: " User {\n" src: (source__CFlag) ) (SourceLine line_num: 8 content: " name = \"z\"\n" src: ...0x7f364287ef10 ) (SourceLine line_num: 9 content: " }\n" src: ...0x7f364287ef10 ) ] ) do_fork: T ) ] redirects: [] right: ) lines: [] ) do_fork: T ) ] redirects: [] right: ) lines: [] ) do_fork: T ) ] ) ===== CASE: -n -c hay define Package/SHELL/User Package foo { SHELL bob { # Disallowed # a = b User { x=1 } } } ===== x=1 ^~ [ -c flag ]:9: Use var/setvar to assign in YSH OK test-hay-shell-assign *** Running test-int-literals ===== CASE: -n -c = 42 ===== (command.Expr keyword: e:(expr.Const c:)) ===== CASE: -n -c = 42_ ===== = 42_ ^ [ -c flag ]:1: Units suffix not implemented ===== CASE: -n -c = 42_0_ ===== = 42_0_ ^ [ -c flag ]:1: Units suffix not implemented ===== CASE: -n -c = _42 ===== (command.Expr keyword: pos_args: [ (expr.Compare left: (expr.Const c:) ops: [] comparators: [(expr.Var name:)] ) ] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c assert [ 42 === x ] ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [ (expr.Compare left: (expr.Const c:) ops: [] comparators: [(expr.Var name:)] ) ] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c assert [42, 43] ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Const c:) (expr.Const c:)] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c assert [42, named=true] ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Const c:)] named_args: [(NamedArg name: value:(expr.Const c:))] right: ) do_fork: T ) ===== CASE: -n -c assert [42, named=true]; echo hi ===== (command.CommandList children: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Const c:)] named_args: [ (NamedArg name: value: (expr.Const c:) ) ] right: ) do_fork: T ) terminator: ) (command.Simple blame_tok: more_env:[] words:[{} {}] redirects:[] do_fork:T) ] ) ===== CASE: -n -c assert [42, named=true] { echo hi } ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Const c:)] named_args: [(NamedArg name: value:(expr.Const c:))] right: ) block: (LiteralBlock brace_group: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) lines: [(SourceLine line_num:1 content:"assert [42, named=true] { echo hi }" src:(source__CFlag))] ) do_fork: T ) ===== CASE: -n -c assert [42, named=true]{ echo hi } ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Const c:)] named_args: [(NamedArg name: value:(expr.Const c:))] right: ) block: (LiteralBlock brace_group: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) lines: [(SourceLine line_num:1 content:"assert [42, named=true]{ echo hi }" src:(source__CFlag))] ) do_fork: T ) ===== CASE: -n -c assert *.[ch] ===== (command.Simple blame_tok: more_env: [] words: [{} { <.> }] redirects: [] do_fork: T ) ===== CASE: -n -c assert 42[ch] ===== (command.Simple blame_tok: more_env: [] words: [{} {<42> }] redirects: [] do_fork: T ) ===== CASE: -n -c echo[] ===== (command.Simple blame_tok: more_env: [] words: [{ }] redirects: [] do_fork: T ) ===== CASE: -n -c assert [4 ===== assert [4 ^ [ -c flag ]:1: Syntax error in expression (near Id.Eof_Real) ===== CASE: -n -c assert [ 4 ===== assert [ 4 ^ [ -c flag ]:1: Syntax error in expression (near Id.Eof_Real) ===== CASE: -n -c json write (42) >out ===== (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [(Redir op:"> loc:(redir_loc.Fd fd:1) arg:{})] typed_args: (ArgList left: pos_args: [(expr.Const c:)] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c json write >out (42) ===== (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [(Redir op:"> loc:(redir_loc.Fd fd:1) arg:{})] typed_args: (ArgList left: pos_args: [(expr.Const c:)] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c [ x = y ] ===== (command.Simple blame_tok: more_env: [] words: [{} {} {}] redirects: [] do_fork: T ) OK test-lazy-arg-list *** Running test-make-these-nicer ===== CASE: -n -c = ===== = ^ [ -c flag ]:1: Syntax error in expression (near Id.Eof_Real) ===== CASE: -n -c call ===== call ^ [ -c flag ]:1: Syntax error in expression (near Id.Eof_Real) ===== CASE: -n -c const d = { name: 42 } ===== const d = { name: ^ [ -c flag ]:1: Syntax error in expression (near Id.Op_Newline) OK test-make-these-nicer *** Running test-multiline-string ===== CASE: -n -c echo u''' hi ''' ===== (command.Simple blame_tok: more_env: [] words: [ {} { (SingleQuoted left: tokens: [] right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo b''' hi ''' ===== (command.Simple blame_tok: more_env: [] words: [ {} { (SingleQuoted left: tokens: [] right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo b''' hi '' ===== echo b''' ^ [ -c flag ]:1: Unexpected EOF in single-quoted string that began here ===== CASE: -n -c echo r''' hi '''bad ===== '''bad ^~~ [ -c flag ]:3: Unexpected token after YSH single-quoted string ===== CASE: -n -c echo u''' hi '''bad ===== '''bad ^~~ [ -c flag ]:3: Unexpected token after YSH single-quoted string ===== CASE: -n -c echo """ hi """bad ===== """bad ^~~ [ -c flag ]:3: Unexpected parts after triple quoted string OK test-multiline-string *** Running test-no-const ===== CASE: -n -c const x = 42 ===== (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (expr.Const c:) ) ===== CASE: -n -c proc p { const x = 42 } ===== const x = 42 ^~~~~ [ -c flag ]:3: const can't be inside proc or func. Use var instead. ===== CASE: -n -c func f() { const x = 42 } ===== const x = 42 ^~~~~ [ -c flag ]:3: const can't be inside proc or func. Use var instead. OK test-no-const *** Running test-oils-issue-1118 ===== CASE: -n -c var snippets = [{status: 42}] for snippet in (snippets) { if (snippet["status"] === 0) { echo hi } # The $ causes a weird error if ($snippet["status"] === 0) { echo hi } } ===== if ($snippet["status"] === 0) { ^~~~~~~~ [ -c flag ]:9: In expressions, remove $ and use `snippet`, or sometimes "$snippet" ===== CASE: -n -c var content = [ 1, 2, 4 ] var count = 0 # The $ causes a weird error while (count < $len(content)) { setvar count += 1 } ===== while (count < $len(content)) { ^~~~ [ -c flag ]:6: In expressions, remove $ and use `len`, or sometimes "$len" OK test-oils-issue-1118 *** Running test-parse-at ===== CASE: -n -c echo @ ===== echo @ ^ [ -c flag ]:1: Literal @ starting a word must be quoted (parse_at_all) ===== CASE: -n -c echo @@ ===== echo @@ ^ [ -c flag ]:1: Literal @ starting a word must be quoted (parse_at_all) ===== CASE: -n -c echo @{foo} ===== echo @{foo} ^ [ -c flag ]:1: Literal @ starting a word must be quoted (parse_at_all) ===== CASE: -n -c echo @/foo/ ===== echo @/foo/ ^ [ -c flag ]:1: Literal @ starting a word must be quoted (parse_at_all) ===== CASE: -n -c echo @"foo" ===== echo @"foo" ^ [ -c flag ]:1: Literal @ starting a word must be quoted (parse_at_all) OK test-parse-at *** Running test-parse-backslash ===== CASE: -n -c echo \( ===== (command.Simple blame_tok: more_env: [] words: [{} {(word_part.EscapedLiteral token: ch:"(")}] redirects: [] do_fork: T ) ===== CASE: -n -c echo \; ===== (command.Simple blame_tok: more_env: [] words: [{} {(word_part.EscapedLiteral token: ch:";")}] redirects: [] do_fork: T ) ===== CASE: -n -c echo ~ ===== (command.Simple blame_tok: more_env: [] words: [{} {(word_part.TildeSub token:)}] redirects: [] do_fork: T ) ===== CASE: -n -c echo \! ===== (command.Simple blame_tok: more_env: [] words: [{} {(word_part.EscapedLiteral token: ch:"!")}] redirects: [] do_fork: T ) ===== CASE: -n -c echo \% ===== (command.Simple blame_tok: more_env: [] words: [{} {(word_part.EscapedLiteral token: ch:"%")}] redirects: [] do_fork: T ) ===== CASE: -n -c echo \# ===== (command.Simple blame_tok: more_env: [] words: [{} {(word_part.EscapedLiteral token: ch:"#")}] redirects: [] do_fork: T ) ===== CASE: -n -c echo \. ===== echo \. ^~ [ -c flag ]:1: Invalid char escape (parse_backslash) ===== CASE: -n -c echo \- ===== echo \- ^~ [ -c flag ]:1: Invalid char escape (parse_backslash) ===== CASE: -n -c echo \/ ===== echo \/ ^~ [ -c flag ]:1: Invalid char escape (parse_backslash) ===== CASE: -n -c echo \a ===== echo \a ^~ [ -c flag ]:1: Invalid char escape (parse_backslash) ===== CASE: -n -c echo \Z ===== echo \Z ^~ [ -c flag ]:1: Invalid char escape (parse_backslash) ===== CASE: -n -c echo \0 ===== echo \0 ^~ [ -c flag ]:1: Invalid char escape (parse_backslash) ===== CASE: -n -c echo \9 ===== echo \9 ^~ [ -c flag ]:1: Invalid char escape (parse_backslash) ===== CASE: -n -c echo \. \- \/ \a \Z \0 \9 ===== (command.Simple blame_tok: more_env: [] words: [ {} {(word_part.EscapedLiteral token: ch:.)} {(word_part.EscapedLiteral token: ch:-)} {(word_part.EscapedLiteral token: ch:/)} {(word_part.EscapedLiteral token: ch:a)} {(word_part.EscapedLiteral token: ch:Z)} {(word_part.EscapedLiteral token: ch:0)} {(word_part.EscapedLiteral token: ch:9)} ] redirects: [] do_fork: T ) OK test-parse-backslash *** Running test-parse-brace ===== CASE: -n -c if test -f foo{ echo hi } ===== if test -f foo{ echo hi } ^~~ [ -c flag ]:1: Word has unbalanced { }. Maybe add a space or quote it like \{ OK test-parse-brace *** Running test-place-expr ===== CASE: -n -c read (&x) ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Place blame_tok: var_name:x ops:[])] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c read (&x[0]) ===== read (&x[0]) ^ [ -c flag ]:1: Places in containers not implemented yet ===== CASE: -n -c read (&x[0][1]) ===== read (&x[0][1]) ^ [ -c flag ]:1: Places in containers not implemented yet ===== CASE: -n -c read (&x.key.other) ===== read (&x.key.other) ^ [ -c flag ]:1: Places in containers not implemented yet ===== CASE: -n -c read (&x + 1) ===== (command.Simple blame_tok: more_env: [] words: [{}] redirects: [] typed_args: (ArgList left: pos_args: [ (expr.Binary op: left: (expr.Place blame_tok: var_name:x ops:[]) right: (expr.Const c:) ) ] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c read (&42) ===== read (&42) ^~ [ -c flag ]:1: Syntax error in expression (near Id.Expr_DecInt) ===== CASE: -n -c read (&+) ===== read (&+) ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Plus) ===== CASE: -n -c read (&(x)) ===== read (&(x)) ^ [ -c flag ]:1: Syntax error in expression (near Id.Op_LParen) OK test-place-expr *** Running test-proc-args ===== CASE: -n -c json write (x) ===== (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c echo $(json write (x)) ===== (command.Simple blame_tok: more_env: [] words: [ {} { (CommandSub left_token: child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [] right: ) do_fork: T ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c var result = $(json write (x)) ===== (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (CommandSub left_token: child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [] right: ) do_fork: T ) right: ) ) ===== CASE: -n -c json write (x, y); echo hi ===== (command.CommandList children: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Var name:) (expr.Var name:)] named_args: [] right: ) do_fork: T ) terminator: ) (command.Simple blame_tok: more_env:[] words:[{} {}] redirects:[] do_fork:T) ] ) ===== CASE: -n -c json write (x, name = "value") echo hi ===== (command.CommandList children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [(NamedArg name: value:(DQ ))] right: ) do_fork: T ) (command.Simple blame_tok: more_env:[] words:[{} {}] redirects:[] do_fork:T) ] ) ===== CASE: -n -c json write (x) { echo hi } ===== (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [] right: ) block: (LiteralBlock brace_group: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) lines: [(SourceLine line_num:1 content:"json write (x) { echo hi }" src:(source__CFlag))] ) do_fork: T ) ===== CASE: -n -c json write (x) { echo hi } ===== (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [] right: ) block: (LiteralBlock brace_group: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) lines: [ (SourceLine line_num:2 content:"json write (x) {\n" src:(source__CFlag)) (SourceLine line_num:3 content:" echo hi\n" src:...0x7fad1d47cf10) (SourceLine line_num:4 content:"}" src:...0x7fad1d47cf10) ] ) do_fork: T ) ===== CASE: -n -c json write ( x, y, z ) ===== (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] typed_args: (ArgList left: pos_args: [ (expr.Var name:) (expr.Var name:) (expr.Var name:) ] named_args: [] right: ) do_fork: T ) ===== CASE: -n -c json write () ===== json write () ^ [ -c flag ]:1: Empty arg list not allowed ===== CASE: -n -c json write ( ) ===== json write ( ) ^ [ -c flag ]:1: Empty arg list not allowed ===== CASE: -n -c json write(x) ===== json write(x) ^ [ -c flag ]:1: Space required before ( ===== CASE: -n -c json write() ===== json write() ^ [ -c flag ]:1: Space required before ( ===== CASE: -n -c f(x) ===== f(x) ^ [ -c flag ]:1: Space required before ( OK test-proc-args *** Running test-proc-def ===== CASE: -n -c proc p(w) { var w = foo } ===== proc p(w) { var w = foo } ^ [ -c flag ]:1: 'w' was already declared ===== CASE: -n -c proc p(w; p) { var p = foo } ===== proc p(w; p) { var p = foo } ^ [ -c flag ]:1: 'p' was already declared ===== CASE: -n -c proc p(w; p; n, n2) { var n2 = foo } ===== proc p(w; p; n, n2) { var n2 = foo } ^~ [ -c flag ]:1: 'n2' was already declared ===== CASE: -n -c proc p(w; p; n, n2; b) { var b = foo } ===== proc p(w; p; n, n2; b) { var b = foo } ^ [ -c flag ]:1: 'b' was already declared OK test-proc-def *** Running test-proc-sig ===== CASE: -n -c proc f[] { echo hi } ===== proc f[] { echo hi } ^~ [ -c flag ]:1: Invalid proc name 'f[' ===== CASE: -n -c proc : { echo hi } ===== proc : { echo hi } ^ [ -c flag ]:1: Invalid proc name ':' ===== CASE: -n -c proc foo::bar { echo hi } ===== proc foo::bar { echo hi } ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Colon) OK test-proc-sig *** Running test-regex-literals ===== CASE: -n -c var x = / ! / ===== var x = / ! / ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Slash) ===== CASE: -n -c var x = / ![a-z] / ===== (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (Eggex left: regex: (re.CharClassLiteral negated: T terms: [(class_literal_term.Range start: end:)] ) flags: [] canonical_flags: "" ) ) ===== CASE: -n -c var x = / !d / ===== (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (Eggex left: regex: (PerlClass negated: name:d) flags: [] canonical_flags: "" ) ) ===== CASE: -n -c var x = / !! / ===== var x = / !! / ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Slash) ===== CASE: -n -c var x = /[a-zA-Z]/ ===== var x = /[a-zA-Z]/ ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Minus) ===== CASE: -n -c var x = /[a-z0-9]/ ===== var x = /[a-z0-9]/ ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Minus) ===== CASE: -n -c var x = /[a-zz]/ ===== var x = /[a-zz]/ ^~ [ -c flag ]:1: Range start/end shouldn't have more than one character ===== CASE: -n -c var x = /['ab'-'z']/ ===== var x = /['ab'-'z']/ ^ [ -c flag ]:1: Range start/end shouldn't have more than one character ===== CASE: -n -c var x = /[$a-${z}]/ ===== var x = /[$a-${z}]/ ^~ [ -c flag ]:1: Syntax error in expression (near Id.VSub_DollarName) ===== CASE: -n -c var x = /[abc]/ ===== var x = /[abc]/ ^~~ [ -c flag ]:1: 'abc' isn't a character class ===== CASE: -n -c var x = /[% _]/ ===== var x = /[% _]/ ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Percent) OK test-regex-literals *** Running test-return-args ===== CASE: -n -c func foo(x) { return (x) } ===== (Func keyword: name: positional: (ParamGroup params:[(Param blame_tok: name:x)]) body: (BraceGroup left: children: [ (command.Retval keyword: val: (expr.Var name:) ) ] redirects: [] right: ) ) ===== CASE: -n -c func foo(x) { return () } ===== return () ^~~~~~ [ -c flag ]:3: shell functions can't be defined inside proc or func ===== CASE: -n -c func foo(x) { return (named=x) } ===== return (named=x) ^ [ -c flag ]:3: Typed return expects one argument ===== CASE: -n -c func foo(x) { return (x, named=x) } ===== return (x, named=x) ^ [ -c flag ]:3: Typed return doesn't take named arguments ===== CASE: -n -c func foo(x) { return (x, x) } ===== return (x, x) ^ [ -c flag ]:3: Typed return expects one argument OK test-return-args *** Running test-setvar ===== CASE: -n -c proc p(x) { var y = 1 setvar y = 42 } ===== (Proc keyword: name:

sig: (proc_sig.Closed word:(ParamGroup params:[(Param blame_tok: name:x)])) body: (BraceGroup left: children: [ (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (expr.Const c:) ) (command.Mutation keyword: lhs: [(y_lhs.Var name:)] op: rhs: (expr.Const c:) ) ] redirects: [] right: ) ) ===== CASE: -n -c proc p(x) { var y = 1 setvar L = "L" # ERROR: not declared } ===== setvar L = "L" # ERROR: not declared ^ [ -c flag ]:4: setvar couldn't find matching 'var L' ===== CASE: -n -c proc p(x) { var y = 1 setvar L[0] = "L" # ERROR: not declared } ===== setvar L[0] = "L" # ERROR: not declared ^ [ -c flag ]:4: setvar couldn't find matching 'var L' ===== CASE: -n -c proc p(x) { var y = 1 setvar d.key = "v" # ERROR: not declared } ===== setvar d.key = "v" # ERROR: not declared ^ [ -c flag ]:4: setvar couldn't find matching 'var d' ===== CASE: -n -c proc p(x) { setvar x = "X" # is mutating params allowed? I guess why not. } ===== (Proc keyword: name:

sig: (proc_sig.Closed word:(ParamGroup params:[(Param blame_tok: name:x)])) body: (BraceGroup left: children: [ (command.Mutation keyword: lhs: [(y_lhs.Var name:)] op: rhs: (DQ ) ) ] redirects: [] right: ) ) OK test-setvar *** Running test-sh-assign ===== CASE: -n -c x=y ===== (command.ShAssignment left: children: [ (command.Sentence child: (command.ShAssignment left: ) ) ===== CASE: -n -c func f() { x=y; } ===== func f() { x=y; } ^~ [ -c flag ]:1: Use var/setvar to assign in YSH ===== CASE: -n -c proc p { x=y; } ===== proc p { x=y; } ^~ [ -c flag ]:1: Use var/setvar to assign in YSH ===== CASE: -n -c { x=y; } ===== (BraceGroup left: children: [ (command.Sentence child: (command.ShAssignment left: ) ===== CASE: -n -c ( x=y; ) ===== (command.Subshell left: child: (command.Sentence child: (command.ShAssignment left: tokens: [] right: ) } ] redirects: [] do_fork: T ) terminator: ) ===== CASE: -n -c echo u'hi' ===== (command.Simple blame_tok: more_env: [] words: [ {} { (SingleQuoted left: tokens: [] right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c (echo u'hi') ===== (command.Subshell left: child: (command.Simple blame_tok: more_env: [] words: [ {} { (SingleQuoted left: tokens: [] right: ) } ] redirects: [] do_fork: T ) right: redirects: [] ) ===== CASE: -n -c echo b'hi'trailing ===== echo b'hi'trailing ^~~~~~~~ [ -c flag ]:1: Unexpected token after YSH single-quoted string ===== CASE: -n -c echo b'hi'#notcomment ===== echo b'hi'#notcomment ^ [ -c flag ]:1: Unexpected token after YSH single-quoted string ===== CASE: -n -c echo 'hi'#notcomment ===== (command.Simple blame_tok: more_env: [] words: [{} {(SQ ) }] redirects: [] do_fork: T ) OK test-string-literals *** Running test-type-expr ===== CASE: -n -c var x: Int = f() ===== (command.VarDecl keyword: lhs: [(NameType name: typ:(TypeExpr tok: name:Int))] rhs: (expr.FuncCall func: (expr.Var name:) args: (ArgList left: pos_args:[] named_args:[] right:) ) ) ===== CASE: -n -c var x Int = f() ===== (command.VarDecl keyword: lhs: [(NameType name: typ:(TypeExpr tok: name:Int))] rhs: (expr.FuncCall func: (expr.Var name:) args: (ArgList left: pos_args:[] named_args:[] right:) ) ) ===== CASE: -n -c proc p (; x Int, y Int; ) { echo hi } ===== (Proc keyword: name:

sig: (proc_sig.Closed positional: (ParamGroup params: [ (Param blame_tok: name: x type: (TypeExpr tok: name:Int) ) (Param blame_tok: name: y type: (TypeExpr tok: name:Int) ) ] ) ) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) ) ===== CASE: -n -c func f (x Int, y Int; z Int = 0) { echo hi } ===== (Func keyword: name: positional: (ParamGroup params: [ (Param blame_tok: name: x type: (TypeExpr tok: name:Int) ) (Param blame_tok: name: y type: (TypeExpr tok: name:Int) ) ] ) named: (ParamGroup params: [ (Param blame_tok: name: z type: (TypeExpr tok: name:Int) default_val: (expr.Const c:) ) ] ) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) ) OK test-type-expr *** Running test-units-suffix ===== CASE: -n -c = 100 M M ===== = 100 M M ^ [ -c flag ]:1: Syntax error in expression (near Id.Expr_Name) ===== CASE: -n -c = 100 M; echo ===== = 100 M; echo ^ [ -c flag ]:1: Units suffix not implemented ===== CASE: -n -c = 100 Mi; echo ===== = 100 Mi; echo ^~ [ -c flag ]:1: Units suffix not implemented ===== CASE: -n -c = 9.9 Mi; echo ===== = 9.9 Mi; echo ^~ [ -c flag ]:1: unix suffix implemented ===== CASE: -n -c = 9.9e-1 Mi; echo ===== = 9.9e-1 Mi; echo ^~ [ -c flag ]:1: unix suffix implemented ===== CASE: -n -c = 100Mi ===== = 100Mi ^~ [ -c flag ]:1: Units suffix not implemented ===== CASE: -n -c = [100 Mi, 200 Mi] ===== = [100 Mi, 200 Mi] ^~ [ -c flag ]:1: Units suffix not implemented ===== CASE: -n -c = {[42 Ki]: 43 Ki} ===== = {[42 Ki]: 43 Ki} ^~ [ -c flag ]:1: Units suffix not implemented OK test-units-suffix *** Running test-var-decl ===== CASE: -n -c proc p(x) { echo hi var x = 2 # Cannot redeclare param } ===== var x = 2 # Cannot redeclare param ^ [ -c flag ]:4: 'x' was already declared ===== CASE: -n -c proc p { var x = 1 echo hi var x = 2 # Cannot redeclare local } ===== var x = 2 # Cannot redeclare local ^ [ -c flag ]:5: 'x' was already declared ===== CASE: -n -c proc p(x, :out) { var out = 2 # Cannot redeclare out param } ===== proc p(x, :out) { ^ [ -c flag ]:2: Syntax error in expression (near Id.Arith_Colon) ===== CASE: -n -c proc p { var out = 2 # Cannot redeclare out param cd /tmp { var out = 3 } } ===== var out = 3 ^~~ [ -c flag ]:5: 'out' was already declared ===== CASE: -n -c var x = 1 proc p { echo hi var x = 2 } proc p2 { var x = 3 } ===== (command.CommandList children: [ (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (expr.Const c:) ) (Proc keyword: name:

sig: (proc_sig__Open) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (expr.Const c:) ) ] redirects: [] right: ) ) (Proc keyword: name: sig: ...0x7f17877905d0 body: (BraceGroup left: children: [ (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (expr.Const c:) ) ] redirects: [] right: ) ) ] ) OK test-var-decl *** Running test-ysh-case ===== CASE: -n -c case (x) { (else) { = 1; } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat__Else) middle: action: [ (command.Sentence child: (command.Expr keyword: ) ] arms_end: redirects: [] ) ===== CASE: -n -c var myexpr = ^[123] case (123) { (myexpr) { echo 1 } } ===== (command.CommandList children: [ (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (expr.Literal inner:(expr.Const c:)) ) (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Const c:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Var name:)]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {<1>}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ] ) ===== CASE: -n -c case (x) { (else) { echo 1 } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat__Else) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {<1>}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { (else) { = 1 } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat__Else) middle: action: [(command.Expr keyword: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { (else) { = 1 } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat__Else) middle: action: [(command.Expr keyword: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { (else) { = 1 } # Comment } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat__Else) middle: action: [(command.Expr keyword: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (3) { (3) { echo hi } # comment line } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Const c:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { (else) { echo 1 } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat__Else) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {<1>}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { (else) { echo } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat__Else) middle: action: [(command.Simple blame_tok: more_env:[] words:[{}] redirects:[] do_fork:T)] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { *.py { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{ <.py>}]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { (obj.attr) { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs: [ (Attribute obj: (expr.Var name:) op: attr: ctx: expr_context.Store ) ] ) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { (0) { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { ("main.py") { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(DQ )]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { ("main.py") { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(DQ )]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { ("main.py") { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(DQ )]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { ("main.py") { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(DQ )]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { ("main.py") { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(DQ )]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (foo) { ("main.py") { echo "python" } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs:[(DQ )]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {(DQ )}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (add(10, 32)) { (40 + 2) { echo Found the answer } (else) { echo Incorrect } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e: (expr.FuncCall func: (expr.Var name:) args: (ArgList left: pos_args: [(expr.Const c:) (expr.Const c:)] named_args: [] right: ) ) ) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs: [ (expr.Binary op: left: (expr.Const c:) right: (expr.Const c:) ) ] ) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {} {} {}] redirects: [] do_fork: T ) ] right: ) (CaseArm left: pattern: (pat__Else) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (file) { / dot* '.py' / { echo Python } / dot* ('.cc' | '.h') / { echo C++ } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (Eggex left: regex: (re.Seq children: [ (re.Repeat child: op: (re_repeat.Op op:) ) (SQ <.py>) ] ) flags: [] canonical_flags: "" ) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) (CaseArm left: pattern: (Eggex left: regex: (re.Seq children: [ (re.Repeat child: op: (re_repeat.Op op:) ) (re.Group child:(re.Alt children:[(SQ <.cc>) (SQ <.h>)])) ] ) flags: [] canonical_flags: "" ) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} { }] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (lang) { en-US | en-CA | en-UK { echo Hello } fr-FR | fr-CA { echo Bonjour } (else) { echo o/ } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{} {} {}]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) (CaseArm left: pattern: (pat.Words words:[{} {}]) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) (CaseArm left: pattern: (pat__Else) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (num) { (1) | (2) { echo number } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs: [(expr.Const c:) (expr.Const c:)] ) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (num) { (1) | (2) | (3) | (4) | (5) { echo small } (else) { echo large } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.YshExprs exprs: [ (expr.Const c:) (expr.Const c:) (expr.Const c:) (expr.Const c:) (expr.Const c:) ] ) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) (CaseArm left: pattern: (pat__Else) middle: action: [ (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (add(10, 32)) { (40 + 2) { echo Found the answer } (else) { echo Incorrect } } ===== case ^ [ -c flag ]:2: Expected a word to match against ===== CASE: -n -c case (file) { ('README') | / dot* '.md' / { echo Markdown } } ===== case (file) ^ [ -c flag ]:2: Expected word type Id.Lit_LBrace, got Id.Op_Newline ===== CASE: -n -c case (file) { { echo Python } } ===== case (file) ^ [ -c flag ]:2: Expected word type Id.Lit_LBrace, got Id.Op_Newline ===== CASE: -n -c case (file) { cc h { echo C++ } } ===== case (file) ^ [ -c flag ]:2: Expected word type Id.Lit_LBrace, got Id.Op_Newline ===== CASE: -n -c case (lang) { en-US | ('en-CA') | / 'en-UK' / { echo Hello } } ===== | ('en-CA') ^ [ -c flag ]:4: Expected case pattern ===== CASE: -n -c case (lang) { else) { echo o/ } } ===== else) { ^ [ -c flag ]:3: Expected word type Id.Lit_LBrace, got Id.Op_RParen ===== CASE: -n -c case (num) { (1) | (2) | (3) | (4) | (5) { echo small } (6) | (else) { echo large } } ===== (6) | (else) { ^~~~ [ -c flag ]:8: Syntax error in expression (near Id.Expr_Else) ===== CASE: -n -c case $foo { ("main.py") { echo "python" } } ===== case $foo { ^ [ -c flag ]:2: Expected word type Id.KW_In, got Id.Lit_LBrace ===== CASE: -n -c case (x) { *.py { echo "python" } } ===== case (x) ^ [ -c flag ]:2: Expected word type Id.Lit_LBrace, got Id.Op_Newline ===== CASE: -n -c case (foo) in *.py { echo "python" } esac ===== case (foo) in ^~ [ -c flag ]:2: Expected word type Id.Lit_LBrace, got Id.KW_In ===== CASE: -n -c case $foo { bar) { echo "python" } } ===== case $foo { ^ [ -c flag ]:2: Expected word type Id.KW_In, got Id.Lit_LBrace ===== CASE: -n -c case (x) { { echo "python" } } ===== echo "python" ^~~~ [ -c flag ]:4: Expected word type Id.Lit_LBrace, got Id.Word_Compound ===== CASE: -n -c case (x { *.py { echo "python" } } ===== case (x { ^ [ -c flag ]:2: Syntax error in expression (near Id.Op_LBrace) ===== CASE: -n -c case (x) { *.py) { echo "python" } } ===== *.py) { echo "python" } ^ [ -c flag ]:3: Expected word type Id.Lit_LBrace, got Id.Op_RParen ===== CASE: -n -c case (x) { word { echo word; } (3) { echo expr; } /'eggex'/ { echo eggex; } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{}]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (Eggex left: regex:(SQ ) flags:[] canonical_flags:"") middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { word { echo word; } (3) { echo expr; } /'eggex'/ { echo eggex; } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{}]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (Eggex left: regex:(SQ ) flags:[] canonical_flags:"") middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { word { echo word; } (3) { echo expr; } /'eggex'/ { echo eggex; } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{}]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (Eggex left: regex:(SQ ) flags:[] canonical_flags:"") middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { word { echo word; } (3) { echo expr; } /'eggex'/ { echo eggex; } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{}]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (Eggex left: regex:(SQ ) flags:[] canonical_flags:"") middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { word { echo word; } (3) { echo expr; } /'eggex'/ { echo eggex; } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{}]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (Eggex left: regex:(SQ ) flags:[] canonical_flags:"") middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) ] arms_end: redirects: [] ) ===== CASE: -n -c case (x) { word { echo word; } (3) { echo expr; } /'eggex'/ { echo eggex; } } ===== (command.Case case_kw: to_match: (case_arg.YshExpr e:(expr.Var name:)) arms_start: arms: [ (CaseArm left: pattern: (pat.Words words:[{}]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (pat.YshExprs exprs:[(expr.Const c:)]) middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) (CaseArm left: pattern: (Eggex left: regex:(SQ ) flags:[] canonical_flags:"") middle: action: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] right: ) ] arms_end: redirects: [] ) OK test-ysh-case *** Running test-ysh-expr ===== CASE: -n -c = 5 mod 3 ===== = 5 mod 3 ^ [ -c flag ]:1: Syntax error in expression (near Id.Expr_DecInt) ===== CASE: -n -c = >>= ===== = >>= ^~~ [ -c flag ]:1: Syntax error in expression (near Id.Arith_DGreatEqual) ===== CASE: -n -c = %( ===== = %( ^ [ -c flag ]:1: Unexpected token in array literal ===== CASE: -n -c = 42, ===== = 42, ^ [ -c flag ]:1: Invalid trailing comma ===== CASE: -n -c = (42,) ===== = (42,) ^ [ -c flag ]:1: Invalid trailing comma ===== CASE: -n -c =a ===== =a ^ [ -c flag ]:1: =word isn't allowed. Hint: add a space after =, or quote it ===== CASE: -n -c var d = {} = d["foo", "bar"] ===== = d["foo", "bar"] ^ [ -c flag ]:3: Only 1 subscript is accepted OK test-ysh-expr *** Running test-ysh-expr-more ===== CASE: -n -c if (5 == 5) { echo yes } ===== if (5 == 5) { echo yes } ^~ [ -c flag ]:1: Use === to be exact, or ~== to convert types ===== CASE: -n -c echo $[join(x)] ===== (command.Simple blame_tok: more_env: [] words: [ {} { (word_part.ExprSub left: child: (expr.FuncCall func: (expr.Var name:) args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [] right: ) ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo $join(x) ===== echo $join(x) ^ [ -c flag ]:1: Space required before ( ===== CASE: -n -c echo @[split(x)] ===== (command.Simple blame_tok: more_env: [] words: [ {} { (word_part.ExprSub left: child: (expr.FuncCall func: (expr.Var name:) args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [] right: ) ) right: ) } ] redirects: [] do_fork: T ) ===== CASE: -n -c echo @[split(x)] two ===== (command.Simple blame_tok: more_env: [] words: [ {} { (word_part.ExprSub left: child: (expr.FuncCall func: (expr.Var name:) args: (ArgList left: pos_args: [(expr.Var name:)] named_args: [] right: ) ) right: ) } {} ] redirects: [] do_fork: T ) ===== CASE: -n -c echo @[split(x)]extra ===== echo @[split(x)]extra ^~~~~ [ -c flag ]:1: Unexpected token after Expr splice OK test-ysh-expr-more *** Running test-ysh-for ===== CASE: -n -c for x in (obj) { echo $x } ===== (command.ForEach keyword: iter_names: [x] iterable: (for_iter.YshExpr e:(expr.Var name:) blame:) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) ] redirects: [] right: ) redirects: [] ) ===== CASE: -n -c for x in (obj); do echo $x done ===== for x in (obj); do ^ [ -c flag ]:2: Expected { after iterable expression ===== CASE: -n -c for x, y in SPAM EGGS; do echo $x done ===== (command.ForEach keyword: iter_names: [x y] iterable: (for_iter.Words words:[{} {}]) semi_tok: body: (command.DoGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) ] right: ) redirects: [] ) ===== CASE: -n -c for x-y in SPAM EGGS; do echo $x done ===== for x-y in SPAM EGGS; do ^~~ [ -c flag ]:2: Invalid loop variable name 'x-y' ===== CASE: -n -c for x, y, z in SPAM EGGS; do echo $x done ===== for x, y, z in SPAM EGGS; do ^~~ [ -c flag ]:2: Expected at most 2 loop variables ===== CASE: -n -c for w, x, y, z in SPAM EGGS; do echo $x done ===== for w, x, y, z in SPAM EGGS; do ^ [ -c flag ]:2: Unexpected word after 3 loop variables ===== CASE: -n -c for x, y in SPAM EGGS do echo $x done ===== (command.ForEach keyword: iter_names: [x y] iterable: (for_iter.Words words:[{} {}]) body: (command.DoGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName x)}] redirects: [] do_fork: T ) ] right: ) redirects: [] ) ===== CASE: -n -c for const in (x) { echo $var } ===== (command.ForEach keyword: iter_names: [const] iterable: (for_iter.YshExpr e:(expr.Var name:) blame:) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {($ Id.VSub_DollarName var)}] redirects: [] do_fork: T ) ] redirects: [] right: ) redirects: [] ) OK test-ysh-for *** Running test-ysh-nested-proc-func ===== CASE: -n -c proc p { echo 1; proc f { echo f }; echo 2 } ===== proc p { echo 1; proc f { echo f }; echo 2 } ^~~~ [ -c flag ]:1: procs must be defined at the top level ===== CASE: -n -c func f() { echo 1; proc f { echo f }; echo 2 } ===== func f() { echo 1; proc f { echo f }; echo 2 } ^~~~ [ -c flag ]:1: procs must be defined at the top level ===== CASE: -n -c proc p { echo 1; func f() { echo f }; echo 2 } ===== proc p { echo 1; func f() { echo f }; echo 2 } ^~~~ [ -c flag ]:1: funcs must be defined at the top level ===== CASE: -n -c func f() { echo 1; func f2() { echo f }; echo 2 } ===== func f() { echo 1; func f2() { echo f }; echo 2 } ^~~~ [ -c flag ]:1: funcs must be defined at the top level ===== CASE: -n -c proc p { echo 1; +weird() { echo f; }; echo 2 } ===== proc p { echo 1; +weird() { echo f; }; echo 2 } ^ [ -c flag ]:1: shell functions can't be defined inside proc or func ===== CASE: -n -c proc p { echo 1; function f { echo f; }; echo 2 } ===== proc p { echo 1; function f { echo f; }; echo 2 } ^~~~~~~~ [ -c flag ]:1: shell functions can't be defined inside proc or func ===== CASE: -n -c f() { echo 1; proc inner { echo inner; }; echo 2; } ===== f() { echo 1; proc inner { echo inner; }; echo 2; } ^~~~ [ -c flag ]:1: procs must be defined at the top level ===== CASE: -n -c f() { echo 1; g() { echo g; }; echo 2; } ===== (command.ShFunction name_tok: name: f body: (BraceGroup left: children: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {<1>}] redirects: [] do_fork: T ) terminator: ) (command.Sentence child: (command.ShFunction name_tok: name: g body: (BraceGroup left: children: [ (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {}] redirects: [] do_fork: T ) terminator: ) ] redirects: [] right: ) ) terminator: ) (command.Sentence child: (command.Simple blame_tok: more_env: [] words: [{} {<2>}] redirects: [] do_fork: T ) terminator: ) ] redirects: [] right: ) ) ===== CASE: -n -c proc p() { shopt --unset errexit { false hi } } ===== (Proc keyword: name:

sig: (proc_sig.Closed) body: (BraceGroup left: children: [ (command.Simple blame_tok: more_env: [] words: [{} {<--unset>} {}] redirects: [] block: (LiteralBlock brace_group: (BraceGroup left: children: [ (command.Simple blame_tok: <"false"> more_env: [] words: [{<"false">} {}] redirects: [] do_fork: T ) ] redirects: [] right: ) lines: [ (SourceLine line_num: 1 content: "proc p() { shopt --unset errexit { false hi } }" src: (source__CFlag) ) ] ) do_fork: T ) ] redirects: [] right: ) ) OK test-ysh-nested-proc-func *** Running test-ysh-var ===== CASE: -n -c var x = 1 + ===== var x = 1 + ^ [ -c flag ]:1: Syntax error in expression (near Id.Eof_Real) ===== CASE: -n -c var x = * ===== var x = * ^ [ -c flag ]:1: Syntax error in expression (near Id.Arith_Star) ===== CASE: -n -c var x = @($(cat < lhs: [(NameType name:)] rhs: (CommandSub left_token: child: (command.Sentence child: (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (expr.Const c:) ) terminator: ) right: ) ) ===== CASE: -n -c var x = $(var x = 1 ) ===== (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (CommandSub left_token: child: (command.VarDecl keyword: lhs: [(NameType name:)] rhs: (expr.Const c:) ) right: ) ) ===== CASE: -n -c var x = $(var x = 1) ===== var x = $(var x = 1) ^ [ -c flag ]:1: Syntax error in expression (near Id.Eof_RParen) ===== CASE: -n -c var x = $(var x = 1; )) ===== var x = $(var x = 1; )) ^ [ -c flag ]:1: Syntax error in expression (near Id.Op_RParen) ===== CASE: -n -c var x = $(var x = 1; ) ) ===== var x = $(var x = 1; ) ) ^ [ -c flag ]:1: Syntax error in expression (near Id.Op_RParen) OK test-ysh-var test/ysh-parse-errors.sh: 40 tests passed.