diff --git a/ruby/ql/test/library-tests/ast/Ast.expected b/ruby/ql/test/library-tests/ast/Ast.expected index 6263cb8919b5..0bece506bfb4 100644 --- a/ruby/ql/test/library-tests/ast/Ast.expected +++ b/ruby/ql/test/library-tests/ast/Ast.expected @@ -1458,6 +1458,50 @@ control/conditionals.rb: # 67| getBranch/getThen: [StmtSequence] then ... # 68| getBranch/getElse: [StmtSequence] else ... # 69| getStmt: [LocalVariableAccess] c +# 73| getStmt: [IfExpr] if ... +# 73| getCondition: [LogicalAndExpr] ... && ... +# 73| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] a +# 73| getAnOperand/getArgument/getRightOperand: [LocalVariableAccess] b +# 73| getBranch/getThen: [StmtSequence] then ... +# 74| getStmt: [LocalVariableAccess] c +# 78| getStmt: [IfExpr] if ... +# 78| getCondition: [LogicalAndExpr] ... && ... +# 78| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] a +# 79| getAnOperand/getArgument/getRightOperand: [LocalVariableAccess] b +# 79| getBranch/getThen: [StmtSequence] then ... +# 81| getStmt: [LocalVariableAccess] c +# 86| getStmt: [IfExpr] if ... +# 86| getCondition: [LocalVariableAccess] a +# 86| getBranch/getThen: [StmtSequence] then ... +# 87| getStmt: [MethodCall] call to and +# 87| getReceiver: [SelfVariableAccess] self +# 87| getArgument: [LocalVariableAccess] b +# 88| getStmt: [MethodCall] call to then +# 88| getReceiver: [SelfVariableAccess] self +# 89| getStmt: [LocalVariableAccess] c +# 102| getStmt: [IfExpr] if ... +# 102| getCondition: [LocalVariableAccess] a +# 102| getBranch/getThen: [StmtSequence] then ... +# 103| getStmt: [MethodCall] call to or +# 103| getReceiver: [SelfVariableAccess] self +# 103| getArgument: [LocalVariableAccess] b +# 104| getStmt: [MethodCall] call to then +# 104| getReceiver: [SelfVariableAccess] self +# 105| getStmt: [LocalVariableAccess] c +# 109| getStmt: [IfExpr] if ... +# 109| getCondition: [LogicalAndExpr] ... && ... +# 109| getAnOperand/getLeftOperand/getReceiver: [LogicalAndExpr] ... && ... +# 109| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] a +# 110| getAnOperand/getArgument/getRightOperand: [LocalVariableAccess] b +# 111| getAnOperand/getArgument/getRightOperand: [LocalVariableAccess] c +# 111| getBranch/getThen: [StmtSequence] then ... +# 113| getStmt: [LocalVariableAccess] d +# 144| getStmt: [IfExpr] if ... +# 144| getCondition: [LogicalAndExpr] ... && ... +# 144| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] a +# 145| getAnOperand/getArgument/getRightOperand: [LocalVariableAccess] b +# 145| getBranch/getThen: [StmtSequence] then ... +# 147| getStmt: [LocalVariableAccess] c constants/constants.rb: # 1| [Toplevel] constants.rb # 1| getStmt: [ModuleDeclaration] ModuleA @@ -2845,63 +2889,77 @@ operations/operations.rb: # 85| getStmt: [AssignBitwiseXorExpr] ... ^= ... # 85| getAnOperand/getLeftOperand: [LocalVariableAccess] baz # 85| getAnOperand/getRightOperand: [LocalVariableAccess] qux -# 87| getStmt: [ClassDeclaration] X -# 88| getStmt: [AssignExpr] ... = ... -# 88| getAnOperand/getLeftOperand: [InstanceVariableAccess] @x -# 88| getReceiver: [SelfVariableAccess] self -# 88| getAnOperand/getRightOperand: [IntegerLiteral] 1 -# 89| getStmt: [AssignAddExpr] ... += ... -# 89| getAnOperand/getLeftOperand: [InstanceVariableAccess] @x -# 89| getReceiver: [SelfVariableAccess] self -# 89| getAnOperand/getRightOperand: [IntegerLiteral] 2 -# 91| getStmt: [AssignExpr] ... = ... -# 91| getAnOperand/getLeftOperand: [ClassVariableAccess] @@y -# 91| getAnOperand/getRightOperand: [IntegerLiteral] 3 -# 92| getStmt: [AssignDivExpr] ... /= ... -# 92| getAnOperand/getLeftOperand: [ClassVariableAccess] @@y -# 92| getAnOperand/getRightOperand: [IntegerLiteral] 4 -# 95| getStmt: [AssignExpr] ... = ... -# 95| getAnOperand/getLeftOperand: [GlobalVariableAccess] $global_var -# 95| getAnOperand/getRightOperand: [IntegerLiteral] 5 -# 96| getStmt: [AssignMulExpr] ... *= ... -# 96| getAnOperand/getLeftOperand: [GlobalVariableAccess] $global_var -# 96| getAnOperand/getRightOperand: [IntegerLiteral] 6 -# 98| getStmt: [AssignExpr] ... = ... -# 98| getAnOperand/getLeftOperand: [ConstantAssignment] CONSTANT1 -# 98| getAnOperand/getRightOperand: [IntegerLiteral] 5 -# 99| getStmt: [AssignAddExpr] ... += ... -# 99| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] CONSTANT2 -# 99| getAnOperand/getRightOperand: [IntegerLiteral] 6 -# 100| getStmt: [AssignLogicalOrExpr] ... ||= ... -# 100| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] CONSTANT3 -# 100| getAnOperand/getRightOperand: [IntegerLiteral] 7 -# 101| getStmt: [AssignLogicalOrExpr] ... ||= ... -# 101| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] MemberConstant -# 101| getScopeExpr: [ConstantReadAccess] Foo -# 101| getAnOperand/getRightOperand: [IntegerLiteral] 8 -# 102| getStmt: [AssignLogicalOrExpr] ... ||= ... -# 102| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] OtherConstant -# 102| getScopeExpr: [MethodCall] call to bar -# 102| getReceiver: [MethodCall] call to foo -# 102| getReceiver: [SelfVariableAccess] self -# 102| getArgument: [IntegerLiteral] 1 -# 102| getAnOperand/getRightOperand: [IntegerLiteral] 7 -# 103| getStmt: [AssignLogicalOrExpr] ... ||= ... -# 103| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] CONSTANT4 -# 103| getAnOperand/getRightOperand: [IntegerLiteral] 7 -# 104| getStmt: [AssignExpr] ... = ... -# 104| getAnOperand/getLeftOperand: [DestructuredLhsExpr] (..., ...) -# 104| getElement: [ConstantAssignment] FOO -# 104| getElement: [ConstantAssignment] BAR -# 104| getElement: [ConstantAssignment] FOO -# 104| getScopeExpr: [LocalVariableAccess] foo -# 104| getAnOperand/getRightOperand: [ArrayLiteral] [...] -# 104| getElement: [IntegerLiteral] 1 -# 104| getElement: [IntegerLiteral] 2 -# 104| getElement: [IntegerLiteral] 3 -# 106| getStmt: [DivExpr] ... / ... -# 106| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] foo -# 107| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 5 +# 88| getStmt: [AssignExpr] ... = ... +# 88| getAnOperand/getLeftOperand: [LocalVariableAccess] foo +# 88| getAnOperand/getRightOperand: [LogicalAndExpr] ... && ... +# 88| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] a +# 89| getAnOperand/getArgument/getRightOperand: [LocalVariableAccess] b +# 95| getStmt: [Method] foo +# 95| getParameter: [SimpleParameter] a +# 95| getDefiningAccess: [LocalVariableAccess] a +# 95| getParameter: [SimpleParameter] b +# 95| getDefiningAccess: [LocalVariableAccess] b +# 96| getStmt: [ReturnStmt] return +# 96| getValue: [LogicalAndExpr] ... && ... +# 96| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] a +# 97| getAnOperand/getArgument/getRightOperand: [LocalVariableAccess] b +# 107| getStmt: [ClassDeclaration] X +# 108| getStmt: [AssignExpr] ... = ... +# 108| getAnOperand/getLeftOperand: [InstanceVariableAccess] @x +# 108| getReceiver: [SelfVariableAccess] self +# 108| getAnOperand/getRightOperand: [IntegerLiteral] 1 +# 109| getStmt: [AssignAddExpr] ... += ... +# 109| getAnOperand/getLeftOperand: [InstanceVariableAccess] @x +# 109| getReceiver: [SelfVariableAccess] self +# 109| getAnOperand/getRightOperand: [IntegerLiteral] 2 +# 111| getStmt: [AssignExpr] ... = ... +# 111| getAnOperand/getLeftOperand: [ClassVariableAccess] @@y +# 111| getAnOperand/getRightOperand: [IntegerLiteral] 3 +# 112| getStmt: [AssignDivExpr] ... /= ... +# 112| getAnOperand/getLeftOperand: [ClassVariableAccess] @@y +# 112| getAnOperand/getRightOperand: [IntegerLiteral] 4 +# 115| getStmt: [AssignExpr] ... = ... +# 115| getAnOperand/getLeftOperand: [GlobalVariableAccess] $global_var +# 115| getAnOperand/getRightOperand: [IntegerLiteral] 5 +# 116| getStmt: [AssignMulExpr] ... *= ... +# 116| getAnOperand/getLeftOperand: [GlobalVariableAccess] $global_var +# 116| getAnOperand/getRightOperand: [IntegerLiteral] 6 +# 118| getStmt: [AssignExpr] ... = ... +# 118| getAnOperand/getLeftOperand: [ConstantAssignment] CONSTANT1 +# 118| getAnOperand/getRightOperand: [IntegerLiteral] 5 +# 119| getStmt: [AssignAddExpr] ... += ... +# 119| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] CONSTANT2 +# 119| getAnOperand/getRightOperand: [IntegerLiteral] 6 +# 120| getStmt: [AssignLogicalOrExpr] ... ||= ... +# 120| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] CONSTANT3 +# 120| getAnOperand/getRightOperand: [IntegerLiteral] 7 +# 121| getStmt: [AssignLogicalOrExpr] ... ||= ... +# 121| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] MemberConstant +# 121| getScopeExpr: [ConstantReadAccess] Foo +# 121| getAnOperand/getRightOperand: [IntegerLiteral] 8 +# 122| getStmt: [AssignLogicalOrExpr] ... ||= ... +# 122| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] OtherConstant +# 122| getScopeExpr: [MethodCall] call to bar +# 122| getReceiver: [MethodCall] call to foo +# 122| getReceiver: [SelfVariableAccess] self +# 122| getArgument: [IntegerLiteral] 1 +# 122| getAnOperand/getRightOperand: [IntegerLiteral] 7 +# 123| getStmt: [AssignLogicalOrExpr] ... ||= ... +# 123| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] CONSTANT4 +# 123| getAnOperand/getRightOperand: [IntegerLiteral] 7 +# 124| getStmt: [AssignExpr] ... = ... +# 124| getAnOperand/getLeftOperand: [DestructuredLhsExpr] (..., ...) +# 124| getElement: [ConstantAssignment] FOO +# 124| getElement: [ConstantAssignment] BAR +# 124| getElement: [ConstantAssignment] FOO +# 124| getScopeExpr: [LocalVariableAccess] foo +# 124| getAnOperand/getRightOperand: [ArrayLiteral] [...] +# 124| getElement: [IntegerLiteral] 1 +# 124| getElement: [IntegerLiteral] 2 +# 124| getElement: [IntegerLiteral] 3 +# 126| getStmt: [DivExpr] ... / ... +# 126| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] foo +# 127| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 5 params/params.rb: # 1| [Toplevel] params.rb # 4| getStmt: [Method] identifier_method_params diff --git a/ruby/ql/test/library-tests/ast/AstDesugar.expected b/ruby/ql/test/library-tests/ast/AstDesugar.expected index 0a1f43b03d58..294438607496 100644 --- a/ruby/ql/test/library-tests/ast/AstDesugar.expected +++ b/ruby/ql/test/library-tests/ast/AstDesugar.expected @@ -965,101 +965,101 @@ operations/operations.rb: # 85| getAnOperand/getRightOperand: [BitwiseXorExpr] ... ^ ... # 85| getAnOperand/getLeftOperand/getReceiver: [LocalVariableAccess] baz # 85| getAnOperand/getArgument/getRightOperand: [LocalVariableAccess] qux -# 89| [AssignAddExpr] ... += ... -# 89| getDesugared: [AssignExpr] ... = ... -# 89| getAnOperand/getLeftOperand: [InstanceVariableAccess] @x -# 89| getReceiver: [SelfVariableAccess] self -# 89| getAnOperand/getRightOperand: [AddExpr] ... + ... -# 89| getAnOperand/getLeftOperand/getReceiver: [InstanceVariableAccess] @x -# 89| getReceiver: [SelfVariableAccess] self -# 89| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 2 -# 92| [AssignDivExpr] ... /= ... -# 92| getDesugared: [AssignExpr] ... = ... -# 92| getAnOperand/getLeftOperand: [ClassVariableAccess] @@y -# 92| getAnOperand/getRightOperand: [DivExpr] ... / ... -# 92| getAnOperand/getLeftOperand/getReceiver: [ClassVariableAccess] @@y -# 92| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 4 -# 96| [AssignMulExpr] ... *= ... -# 96| getDesugared: [AssignExpr] ... = ... -# 96| getAnOperand/getLeftOperand: [GlobalVariableAccess] $global_var -# 96| getAnOperand/getRightOperand: [MulExpr] ... * ... -# 96| getAnOperand/getLeftOperand/getReceiver: [GlobalVariableAccess] $global_var -# 96| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 6 -# 99| [AssignAddExpr] ... += ... -# 99| getDesugared: [AssignExpr] ... = ... -# 99| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] CONSTANT2 -# 99| getAnOperand/getRightOperand: [AddExpr] ... + ... -# 99| getAnOperand/getLeftOperand/getReceiver: [ConstantReadAccess] CONSTANT2 -# 99| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 6 -# 100| [AssignLogicalOrExpr] ... ||= ... -# 100| getDesugared: [AssignExpr] ... = ... -# 100| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] CONSTANT3 -# 100| getAnOperand/getRightOperand: [LogicalOrExpr] ... || ... -# 100| getAnOperand/getLeftOperand/getReceiver: [ConstantReadAccess] CONSTANT3 -# 100| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 7 -# 101| [AssignLogicalOrExpr] ... ||= ... -# 101| getDesugared: [StmtSequence] ... -# 101| getStmt: [AssignExpr] ... = ... -# 101| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__0 -# 101| getAnOperand/getRightOperand: [ConstantReadAccess] Foo -# 101| getStmt: [AssignExpr] ... = ... -# 101| getAnOperand/getLeftOperand: [ConstantAssignment] MemberConstant -# 101| getScopeExpr: [LocalVariableAccess] __synth__0 -# 101| getAnOperand/getRightOperand: [LogicalOrExpr] ... || ... -# 101| getAnOperand/getLeftOperand/getReceiver: [ConstantReadAccess] MemberConstant -# 101| getScopeExpr: [LocalVariableAccess] __synth__0 -# 101| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 8 -# 102| [AssignLogicalOrExpr] ... ||= ... -# 102| getDesugared: [StmtSequence] ... -# 102| getStmt: [AssignExpr] ... = ... -# 102| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__0 -# 102| getAnOperand/getRightOperand: [MethodCall] call to bar -# 102| getReceiver: [MethodCall] call to foo -# 102| getReceiver: [SelfVariableAccess] self -# 102| getArgument: [IntegerLiteral] 1 -# 102| getStmt: [AssignExpr] ... = ... -# 102| getAnOperand/getLeftOperand: [ConstantAssignment] OtherConstant -# 102| getScopeExpr: [LocalVariableAccess] __synth__0 -# 102| getAnOperand/getRightOperand: [LogicalOrExpr] ... || ... -# 102| getAnOperand/getLeftOperand/getReceiver: [ConstantReadAccess] OtherConstant -# 102| getScopeExpr: [LocalVariableAccess] __synth__0 -# 102| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 7 -# 103| [AssignLogicalOrExpr] ... ||= ... -# 103| getDesugared: [AssignExpr] ... = ... -# 103| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] CONSTANT4 -# 103| getAnOperand/getRightOperand: [LogicalOrExpr] ... || ... -# 103| getAnOperand/getLeftOperand/getReceiver: [ConstantReadAccess] CONSTANT4 -# 103| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 7 -# 104| [AssignExpr] ... = ... -# 104| getDesugared: [StmtSequence] ... -# 104| getStmt: [AssignExpr] ... = ... -# 104| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__2 -# 104| getAnOperand/getRightOperand: [LocalVariableAccess] foo -# 104| getStmt: [AssignExpr] ... = ... -# 104| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__3 -# 104| getAnOperand/getRightOperand: [SplatExpr] * ... -# 104| getAnOperand/getOperand/getReceiver: [ArrayLiteral] [...] -# 104| getDesugared: [MethodCall] call to [] -# 104| getReceiver: [ConstantReadAccess] Array -# 104| getArgument: [IntegerLiteral] 1 -# 104| getArgument: [IntegerLiteral] 2 -# 104| getArgument: [IntegerLiteral] 3 -# 104| getStmt: [AssignExpr] ... = ... -# 104| getAnOperand/getLeftOperand: [ConstantAssignment] FOO -# 104| getAnOperand/getRightOperand: [MethodCall] call to [] -# 104| getReceiver: [LocalVariableAccess] __synth__3 -# 104| getArgument: [IntegerLiteral] 0 -# 104| getStmt: [AssignExpr] ... = ... -# 104| getAnOperand/getLeftOperand: [ConstantAssignment] BAR -# 104| getAnOperand/getRightOperand: [MethodCall] call to [] -# 104| getReceiver: [LocalVariableAccess] __synth__3 -# 104| getArgument: [IntegerLiteral] 1 -# 104| getStmt: [AssignExpr] ... = ... -# 104| getAnOperand/getLeftOperand: [ConstantAssignment] FOO -# 104| getScopeExpr: [LocalVariableAccess] __synth__2 -# 104| getAnOperand/getRightOperand: [MethodCall] call to [] -# 104| getReceiver: [LocalVariableAccess] __synth__3 -# 104| getArgument: [IntegerLiteral] 2 +# 109| [AssignAddExpr] ... += ... +# 109| getDesugared: [AssignExpr] ... = ... +# 109| getAnOperand/getLeftOperand: [InstanceVariableAccess] @x +# 109| getReceiver: [SelfVariableAccess] self +# 109| getAnOperand/getRightOperand: [AddExpr] ... + ... +# 109| getAnOperand/getLeftOperand/getReceiver: [InstanceVariableAccess] @x +# 109| getReceiver: [SelfVariableAccess] self +# 109| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 2 +# 112| [AssignDivExpr] ... /= ... +# 112| getDesugared: [AssignExpr] ... = ... +# 112| getAnOperand/getLeftOperand: [ClassVariableAccess] @@y +# 112| getAnOperand/getRightOperand: [DivExpr] ... / ... +# 112| getAnOperand/getLeftOperand/getReceiver: [ClassVariableAccess] @@y +# 112| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 4 +# 116| [AssignMulExpr] ... *= ... +# 116| getDesugared: [AssignExpr] ... = ... +# 116| getAnOperand/getLeftOperand: [GlobalVariableAccess] $global_var +# 116| getAnOperand/getRightOperand: [MulExpr] ... * ... +# 116| getAnOperand/getLeftOperand/getReceiver: [GlobalVariableAccess] $global_var +# 116| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 6 +# 119| [AssignAddExpr] ... += ... +# 119| getDesugared: [AssignExpr] ... = ... +# 119| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] CONSTANT2 +# 119| getAnOperand/getRightOperand: [AddExpr] ... + ... +# 119| getAnOperand/getLeftOperand/getReceiver: [ConstantReadAccess] CONSTANT2 +# 119| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 6 +# 120| [AssignLogicalOrExpr] ... ||= ... +# 120| getDesugared: [AssignExpr] ... = ... +# 120| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] CONSTANT3 +# 120| getAnOperand/getRightOperand: [LogicalOrExpr] ... || ... +# 120| getAnOperand/getLeftOperand/getReceiver: [ConstantReadAccess] CONSTANT3 +# 120| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 7 +# 121| [AssignLogicalOrExpr] ... ||= ... +# 121| getDesugared: [StmtSequence] ... +# 121| getStmt: [AssignExpr] ... = ... +# 121| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__0 +# 121| getAnOperand/getRightOperand: [ConstantReadAccess] Foo +# 121| getStmt: [AssignExpr] ... = ... +# 121| getAnOperand/getLeftOperand: [ConstantAssignment] MemberConstant +# 121| getScopeExpr: [LocalVariableAccess] __synth__0 +# 121| getAnOperand/getRightOperand: [LogicalOrExpr] ... || ... +# 121| getAnOperand/getLeftOperand/getReceiver: [ConstantReadAccess] MemberConstant +# 121| getScopeExpr: [LocalVariableAccess] __synth__0 +# 121| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 8 +# 122| [AssignLogicalOrExpr] ... ||= ... +# 122| getDesugared: [StmtSequence] ... +# 122| getStmt: [AssignExpr] ... = ... +# 122| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__0 +# 122| getAnOperand/getRightOperand: [MethodCall] call to bar +# 122| getReceiver: [MethodCall] call to foo +# 122| getReceiver: [SelfVariableAccess] self +# 122| getArgument: [IntegerLiteral] 1 +# 122| getStmt: [AssignExpr] ... = ... +# 122| getAnOperand/getLeftOperand: [ConstantAssignment] OtherConstant +# 122| getScopeExpr: [LocalVariableAccess] __synth__0 +# 122| getAnOperand/getRightOperand: [LogicalOrExpr] ... || ... +# 122| getAnOperand/getLeftOperand/getReceiver: [ConstantReadAccess] OtherConstant +# 122| getScopeExpr: [LocalVariableAccess] __synth__0 +# 122| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 7 +# 123| [AssignLogicalOrExpr] ... ||= ... +# 123| getDesugared: [AssignExpr] ... = ... +# 123| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] CONSTANT4 +# 123| getAnOperand/getRightOperand: [LogicalOrExpr] ... || ... +# 123| getAnOperand/getLeftOperand/getReceiver: [ConstantReadAccess] CONSTANT4 +# 123| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 7 +# 124| [AssignExpr] ... = ... +# 124| getDesugared: [StmtSequence] ... +# 124| getStmt: [AssignExpr] ... = ... +# 124| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__2 +# 124| getAnOperand/getRightOperand: [LocalVariableAccess] foo +# 124| getStmt: [AssignExpr] ... = ... +# 124| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__3 +# 124| getAnOperand/getRightOperand: [SplatExpr] * ... +# 124| getAnOperand/getOperand/getReceiver: [ArrayLiteral] [...] +# 124| getDesugared: [MethodCall] call to [] +# 124| getReceiver: [ConstantReadAccess] Array +# 124| getArgument: [IntegerLiteral] 1 +# 124| getArgument: [IntegerLiteral] 2 +# 124| getArgument: [IntegerLiteral] 3 +# 124| getStmt: [AssignExpr] ... = ... +# 124| getAnOperand/getLeftOperand: [ConstantAssignment] FOO +# 124| getAnOperand/getRightOperand: [MethodCall] call to [] +# 124| getReceiver: [LocalVariableAccess] __synth__3 +# 124| getArgument: [IntegerLiteral] 0 +# 124| getStmt: [AssignExpr] ... = ... +# 124| getAnOperand/getLeftOperand: [ConstantAssignment] BAR +# 124| getAnOperand/getRightOperand: [MethodCall] call to [] +# 124| getReceiver: [LocalVariableAccess] __synth__3 +# 124| getArgument: [IntegerLiteral] 1 +# 124| getStmt: [AssignExpr] ... = ... +# 124| getAnOperand/getLeftOperand: [ConstantAssignment] FOO +# 124| getScopeExpr: [LocalVariableAccess] __synth__2 +# 124| getAnOperand/getRightOperand: [MethodCall] call to [] +# 124| getReceiver: [LocalVariableAccess] __synth__3 +# 124| getArgument: [IntegerLiteral] 2 params/params.rb: # 8| [HashLiteral] {...} # 8| getDesugared: [MethodCall] call to [] diff --git a/ruby/ql/test/library-tests/ast/TreeSitter.expected b/ruby/ql/test/library-tests/ast/TreeSitter.expected index 04a66cce8472..ab7937969d10 100644 --- a/ruby/ql/test/library-tests/ast/TreeSitter.expected +++ b/ruby/ql/test/library-tests/ast/TreeSitter.expected @@ -2962,6 +2962,71 @@ control/conditionals.rb: # 68| 0: [ReservedWord] else # 69| 1: [Identifier] c # 70| 4: [ReservedWord] end +# 73| 17: [If] If +# 73| 0: [ReservedWord] if +# 73| 1: [Binary] Binary +# 73| 0: [Identifier] a +# 73| 1: [ReservedWord] && +# 73| 2: [Identifier] b +# 73| 2: [Then] Then +# 73| 0: [ReservedWord] then +# 74| 1: [Identifier] c +# 75| 3: [ReservedWord] end +# 78| 18: [If] If +# 78| 0: [ReservedWord] if +# 78| 1: [Binary] Binary +# 78| 0: [Identifier] a +# 79| 1: [ReservedWord] && +# 79| 2: [Identifier] b +# 79| 2: [Then] Then +# 80| 0: [ReservedWord] then +# 81| 1: [Identifier] c +# 82| 3: [ReservedWord] end +# 86| 19: [If] If +# 86| 0: [ReservedWord] if +# 86| 1: [Identifier] a +# 86| 2: [Then] Then +# 87| 0: [Call] Call +# 87| 0: [Identifier] and +# 87| 1: [ArgumentList] ArgumentList +# 87| 0: [Identifier] b +# 88| 1: [Identifier] then +# 89| 2: [Identifier] c +# 90| 3: [ReservedWord] end +# 102| 20: [If] If +# 102| 0: [ReservedWord] if +# 102| 1: [Identifier] a +# 102| 2: [Then] Then +# 103| 0: [Call] Call +# 103| 0: [Identifier] or +# 103| 1: [ArgumentList] ArgumentList +# 103| 0: [Identifier] b +# 104| 1: [Identifier] then +# 105| 2: [Identifier] c +# 106| 3: [ReservedWord] end +# 109| 21: [If] If +# 109| 0: [ReservedWord] if +# 109| 1: [Binary] Binary +# 109| 0: [Binary] Binary +# 109| 0: [Identifier] a +# 110| 1: [ReservedWord] && +# 110| 2: [Identifier] b +# 111| 1: [ReservedWord] && +# 111| 2: [Identifier] c +# 111| 2: [Then] Then +# 112| 0: [ReservedWord] then +# 113| 1: [Identifier] d +# 114| 3: [ReservedWord] end +# 144| 22: [If] If +# 144| 0: [ReservedWord] if +# 144| 1: [Binary] Binary +# 144| 0: [Identifier] a +# 144| 1: [ReservedWord] && +# 145| 2: [Identifier] b +# 145| 2: [Then] Then +# 146| 0: [ReservedWord] then +# 147| 1: [Identifier] c +# 148| 3: [ReservedWord] end # 1| [Comment] # Define some variables used below # 9| [Comment] # If expr with no else # 14| [Comment] # If expr with single else @@ -2974,6 +3039,45 @@ control/conditionals.rb: # 57| [Comment] # Ternary if expr # 60| [Comment] # If expr with empty else (treated as no else) # 66| [Comment] # If expr with empty then (treated as no then) +# 72| [Comment] # If expr with `&&` on same line as condition and then +# 77| [Comment] # If expr with `&&` at the start of a separate line before then +# 84| [Comment] # If expr with `and` at the start of a separate line before then +# 85| [Comment] # NOTE: This is not parsed correctly, `and b` is parsed as a call +# 92| [Comment] # If expr with `||` at the start of a separate line before then +# 93| [Comment] # NOTE: This is not parsed correctly due to the leading `||` +# 94| [Comment] # if a +# 95| [Comment] # || b +# 96| [Comment] # then +# 97| [Comment] # c +# 98| [Comment] # end +# 100| [Comment] # If expr with `or` at the start of a separate line before then +# 101| [Comment] # NOTE: This is not parsed correctly, `or b` is parsed as a call +# 108| [Comment] # If expr with repeated && at the start of a separate line before then +# 116| [Comment] # If expr with alternating && and || at the start of lines +# 117| [Comment] # NOTE: This is not parsed correctly due to the leading `||` +# 118| [Comment] # if a +# 119| [Comment] # && b +# 120| [Comment] # || c +# 121| [Comment] # then +# 122| [Comment] # d +# 123| [Comment] # end +# 125| [Comment] # If expr with operator at start of line and parentheses +# 126| [Comment] # NOTE: This is not parsed correctly due to the leading `||` +# 127| [Comment] # if a +# 128| [Comment] # && (b +# 129| [Comment] # || c) +# 130| [Comment] # then +# 131| [Comment] # d +# 132| [Comment] # end +# 134| [Comment] # If expr with operator at start of line and parentheses +# 135| [Comment] # NOTE: This is not parsed correctly due to the leading `||` +# 136| [Comment] # if a +# 137| [Comment] # || (b +# 138| [Comment] # && c) +# 139| [Comment] # then +# 140| [Comment] # d +# 141| [Comment] # end +# 143| [Comment] # If expr with && at end of line control/loops.rb: # 1| [Program] Program # 2| 0: [Assignment] Assignment @@ -5564,100 +5668,125 @@ operations/operations.rb: # 85| 0: [Identifier] baz # 85| 1: [ReservedWord] ^= # 85| 2: [Identifier] qux -# 87| 63: [Class] Class -# 87| 0: [ReservedWord] class -# 87| 1: [Constant] X -# 88| 2: [BodyStatement] BodyStatement -# 88| 0: [Assignment] Assignment -# 88| 0: [InstanceVariable] @x -# 88| 1: [ReservedWord] = -# 88| 2: [Integer] 1 -# 89| 1: [OperatorAssignment] OperatorAssignment -# 89| 0: [InstanceVariable] @x -# 89| 1: [ReservedWord] += -# 89| 2: [Integer] 2 -# 91| 2: [Assignment] Assignment -# 91| 0: [ClassVariable] @@y -# 91| 1: [ReservedWord] = -# 91| 2: [Integer] 3 -# 92| 3: [OperatorAssignment] OperatorAssignment -# 92| 0: [ClassVariable] @@y -# 92| 1: [ReservedWord] /= -# 92| 2: [Integer] 4 -# 93| 3: [ReservedWord] end -# 95| 64: [Assignment] Assignment -# 95| 0: [GlobalVariable] $global_var -# 95| 1: [ReservedWord] = -# 95| 2: [Integer] 5 -# 96| 65: [OperatorAssignment] OperatorAssignment -# 96| 0: [GlobalVariable] $global_var -# 96| 1: [ReservedWord] *= -# 96| 2: [Integer] 6 -# 98| 66: [Assignment] Assignment -# 98| 0: [Constant] CONSTANT1 -# 98| 1: [ReservedWord] = -# 98| 2: [Integer] 5 -# 99| 67: [OperatorAssignment] OperatorAssignment -# 99| 0: [Constant] CONSTANT2 -# 99| 1: [ReservedWord] += -# 99| 2: [Integer] 6 -# 100| 68: [OperatorAssignment] OperatorAssignment -# 100| 0: [Constant] CONSTANT3 -# 100| 1: [ReservedWord] ||= -# 100| 2: [Integer] 7 -# 101| 69: [OperatorAssignment] OperatorAssignment -# 101| 0: [ScopeResolution] ScopeResolution -# 101| 0: [Constant] Foo -# 101| 1: [ReservedWord] :: -# 101| 2: [Constant] MemberConstant -# 101| 1: [ReservedWord] ||= -# 101| 2: [Integer] 8 -# 102| 70: [OperatorAssignment] OperatorAssignment -# 102| 0: [ScopeResolution] ScopeResolution -# 102| 0: [Call] Call -# 102| 0: [Call] Call -# 102| 0: [Identifier] foo -# 102| 1: [ArgumentList] ArgumentList -# 102| 0: [ReservedWord] ( -# 102| 1: [Integer] 1 -# 102| 2: [ReservedWord] ) -# 102| 1: [ReservedWord] . -# 102| 2: [Identifier] bar -# 102| 1: [ReservedWord] :: -# 102| 2: [Constant] OtherConstant -# 102| 1: [ReservedWord] ||= -# 102| 2: [Integer] 7 -# 103| 71: [OperatorAssignment] OperatorAssignment -# 103| 0: [ScopeResolution] ScopeResolution -# 103| 0: [ReservedWord] :: -# 103| 1: [Constant] CONSTANT4 -# 103| 1: [ReservedWord] ||= -# 103| 2: [Integer] 7 -# 104| 72: [Assignment] Assignment -# 104| 0: [LeftAssignmentList] LeftAssignmentList -# 104| 0: [Constant] FOO -# 104| 1: [ReservedWord] , -# 104| 2: [ScopeResolution] ScopeResolution -# 104| 0: [ReservedWord] :: -# 104| 1: [Constant] BAR -# 104| 3: [ReservedWord] , -# 104| 4: [ScopeResolution] ScopeResolution -# 104| 0: [Identifier] foo -# 104| 1: [ReservedWord] :: -# 104| 2: [Constant] FOO -# 104| 1: [ReservedWord] = -# 104| 2: [Array] Array -# 104| 0: [ReservedWord] [ -# 104| 1: [Integer] 1 -# 104| 2: [ReservedWord] , -# 104| 3: [Integer] 2 -# 104| 4: [ReservedWord] , -# 104| 5: [Integer] 3 -# 104| 6: [ReservedWord] ] -# 106| 73: [Binary] Binary -# 106| 0: [Identifier] foo -# 106| 1: [ReservedWord] / -# 107| 2: [Integer] 5 +# 88| 63: [Assignment] Assignment +# 88| 0: [Identifier] foo +# 88| 1: [ReservedWord] = +# 88| 2: [Binary] Binary +# 88| 0: [Identifier] a +# 89| 1: [ReservedWord] && +# 89| 2: [Identifier] b +# 95| 64: [Method] Method +# 95| 0: [ReservedWord] def +# 95| 1: [Identifier] foo +# 95| 2: [MethodParameters] MethodParameters +# 95| 0: [ReservedWord] ( +# 95| 1: [Identifier] a +# 95| 2: [ReservedWord] , +# 95| 3: [Identifier] b +# 95| 4: [ReservedWord] ) +# 96| 3: [BodyStatement] BodyStatement +# 96| 0: [Return] Return +# 96| 0: [ReservedWord] return +# 96| 1: [ArgumentList] ArgumentList +# 96| 0: [Binary] Binary +# 96| 0: [Identifier] a +# 97| 1: [ReservedWord] && +# 97| 2: [Identifier] b +# 98| 4: [ReservedWord] end +# 107| 65: [Class] Class +# 107| 0: [ReservedWord] class +# 107| 1: [Constant] X +# 108| 2: [BodyStatement] BodyStatement +# 108| 0: [Assignment] Assignment +# 108| 0: [InstanceVariable] @x +# 108| 1: [ReservedWord] = +# 108| 2: [Integer] 1 +# 109| 1: [OperatorAssignment] OperatorAssignment +# 109| 0: [InstanceVariable] @x +# 109| 1: [ReservedWord] += +# 109| 2: [Integer] 2 +# 111| 2: [Assignment] Assignment +# 111| 0: [ClassVariable] @@y +# 111| 1: [ReservedWord] = +# 111| 2: [Integer] 3 +# 112| 3: [OperatorAssignment] OperatorAssignment +# 112| 0: [ClassVariable] @@y +# 112| 1: [ReservedWord] /= +# 112| 2: [Integer] 4 +# 113| 3: [ReservedWord] end +# 115| 66: [Assignment] Assignment +# 115| 0: [GlobalVariable] $global_var +# 115| 1: [ReservedWord] = +# 115| 2: [Integer] 5 +# 116| 67: [OperatorAssignment] OperatorAssignment +# 116| 0: [GlobalVariable] $global_var +# 116| 1: [ReservedWord] *= +# 116| 2: [Integer] 6 +# 118| 68: [Assignment] Assignment +# 118| 0: [Constant] CONSTANT1 +# 118| 1: [ReservedWord] = +# 118| 2: [Integer] 5 +# 119| 69: [OperatorAssignment] OperatorAssignment +# 119| 0: [Constant] CONSTANT2 +# 119| 1: [ReservedWord] += +# 119| 2: [Integer] 6 +# 120| 70: [OperatorAssignment] OperatorAssignment +# 120| 0: [Constant] CONSTANT3 +# 120| 1: [ReservedWord] ||= +# 120| 2: [Integer] 7 +# 121| 71: [OperatorAssignment] OperatorAssignment +# 121| 0: [ScopeResolution] ScopeResolution +# 121| 0: [Constant] Foo +# 121| 1: [ReservedWord] :: +# 121| 2: [Constant] MemberConstant +# 121| 1: [ReservedWord] ||= +# 121| 2: [Integer] 8 +# 122| 72: [OperatorAssignment] OperatorAssignment +# 122| 0: [ScopeResolution] ScopeResolution +# 122| 0: [Call] Call +# 122| 0: [Call] Call +# 122| 0: [Identifier] foo +# 122| 1: [ArgumentList] ArgumentList +# 122| 0: [ReservedWord] ( +# 122| 1: [Integer] 1 +# 122| 2: [ReservedWord] ) +# 122| 1: [ReservedWord] . +# 122| 2: [Identifier] bar +# 122| 1: [ReservedWord] :: +# 122| 2: [Constant] OtherConstant +# 122| 1: [ReservedWord] ||= +# 122| 2: [Integer] 7 +# 123| 73: [OperatorAssignment] OperatorAssignment +# 123| 0: [ScopeResolution] ScopeResolution +# 123| 0: [ReservedWord] :: +# 123| 1: [Constant] CONSTANT4 +# 123| 1: [ReservedWord] ||= +# 123| 2: [Integer] 7 +# 124| 74: [Assignment] Assignment +# 124| 0: [LeftAssignmentList] LeftAssignmentList +# 124| 0: [Constant] FOO +# 124| 1: [ReservedWord] , +# 124| 2: [ScopeResolution] ScopeResolution +# 124| 0: [ReservedWord] :: +# 124| 1: [Constant] BAR +# 124| 3: [ReservedWord] , +# 124| 4: [ScopeResolution] ScopeResolution +# 124| 0: [Identifier] foo +# 124| 1: [ReservedWord] :: +# 124| 2: [Constant] FOO +# 124| 1: [ReservedWord] = +# 124| 2: [Array] Array +# 124| 0: [ReservedWord] [ +# 124| 1: [Integer] 1 +# 124| 2: [ReservedWord] , +# 124| 3: [Integer] 2 +# 124| 4: [ReservedWord] , +# 124| 5: [Integer] 3 +# 124| 6: [ReservedWord] ] +# 126| 75: [Binary] Binary +# 126| 0: [Identifier] foo +# 126| 1: [ReservedWord] / +# 127| 2: [Integer] 5 # 1| [Comment] # Start with assignments to all the identifiers used below, so that they are # 2| [Comment] # interpreted as variables. # 22| [Comment] # Unary operations @@ -5670,6 +5799,17 @@ operations/operations.rb: # 68| [Comment] # Arithmetic assign operations # 76| [Comment] # Logical assign operations # 80| [Comment] # Bitwise assign operations +# 87| [Comment] # Assignments with operation at start of line +# 90| [Comment] # NOTE: This is not parsed correctly, `|| b` is dropped +# 91| [Comment] # bar = a +# 92| [Comment] # || b +# 94| [Comment] # Return with `&&` at start of line +# 100| [Comment] # Return with `||` at start of line +# 101| [Comment] # NOTE: This is not parsed correctly, `|| b` is dropped +# 102| [Comment] # def bar(a, b) +# 103| [Comment] # return a +# 104| [Comment] # || b +# 105| [Comment] # end params/params.rb: # 1| [Program] Program # 4| 0: [Method] Method diff --git a/ruby/ql/test/library-tests/ast/ValueText.expected b/ruby/ql/test/library-tests/ast/ValueText.expected index 283eef73d25b..e0ad853ba83f 100644 --- a/ruby/ql/test/library-tests/ast/ValueText.expected +++ b/ruby/ql/test/library-tests/ast/ValueText.expected @@ -336,6 +336,19 @@ exprValue | control/conditionals.rb:62:5:62:5 | c | 0 | int | | control/conditionals.rb:67:8:67:8 | b | 0 | int | | control/conditionals.rb:69:5:69:5 | c | 0 | int | +| control/conditionals.rb:73:9:73:9 | b | 0 | int | +| control/conditionals.rb:74:5:74:5 | c | 0 | int | +| control/conditionals.rb:79:8:79:8 | b | 0 | int | +| control/conditionals.rb:81:5:81:5 | c | 0 | int | +| control/conditionals.rb:87:9:87:9 | b | 0 | int | +| control/conditionals.rb:89:5:89:5 | c | 0 | int | +| control/conditionals.rb:103:8:103:8 | b | 0 | int | +| control/conditionals.rb:105:5:105:5 | c | 0 | int | +| control/conditionals.rb:110:8:110:8 | b | 0 | int | +| control/conditionals.rb:111:8:111:8 | c | 0 | int | +| control/conditionals.rb:113:5:113:5 | d | 0 | int | +| control/conditionals.rb:145:5:145:5 | b | 0 | int | +| control/conditionals.rb:147:5:147:5 | c | 0 | int | | control/loops.rb:2:7:2:7 | 0 | 0 | int | | control/loops.rb:3:7:3:7 | 0 | 0 | int | | control/loops.rb:4:5:4:5 | 0 | 0 | int | @@ -908,26 +921,27 @@ exprValue | operations/operations.rb:84:9:84:12 | 0x01 | 1 | int | | operations/operations.rb:85:2:85:4 | baz | 0 | int | | operations/operations.rb:85:9:85:11 | qux | 0 | int | -| operations/operations.rb:88:8:88:8 | 1 | 1 | int | -| operations/operations.rb:89:9:89:9 | 2 | 2 | int | -| operations/operations.rb:91:9:91:9 | 3 | 3 | int | -| operations/operations.rb:92:10:92:10 | 4 | 4 | int | -| operations/operations.rb:95:15:95:15 | 5 | 5 | int | -| operations/operations.rb:96:16:96:16 | 6 | 6 | int | -| operations/operations.rb:98:13:98:13 | 5 | 5 | int | -| operations/operations.rb:99:14:99:14 | 6 | 6 | int | -| operations/operations.rb:100:15:100:15 | 7 | 7 | int | -| operations/operations.rb:101:25:101:25 | 8 | 8 | int | -| operations/operations.rb:102:5:102:5 | 1 | 1 | int | -| operations/operations.rb:102:31:102:31 | 7 | 7 | int | -| operations/operations.rb:103:17:103:17 | 7 | 7 | int | -| operations/operations.rb:104:1:104:3 | 0 | 0 | int | -| operations/operations.rb:104:6:104:10 | 1 | 1 | int | -| operations/operations.rb:104:13:104:20 | 2 | 2 | int | -| operations/operations.rb:104:25:104:25 | 1 | 1 | int | -| operations/operations.rb:104:28:104:28 | 2 | 2 | int | -| operations/operations.rb:104:31:104:31 | 3 | 3 | int | -| operations/operations.rb:107:1:107:1 | 5 | 5 | int | +| operations/operations.rb:89:6:89:6 | b | 0 | int | +| operations/operations.rb:108:8:108:8 | 1 | 1 | int | +| operations/operations.rb:109:9:109:9 | 2 | 2 | int | +| operations/operations.rb:111:9:111:9 | 3 | 3 | int | +| operations/operations.rb:112:10:112:10 | 4 | 4 | int | +| operations/operations.rb:115:15:115:15 | 5 | 5 | int | +| operations/operations.rb:116:16:116:16 | 6 | 6 | int | +| operations/operations.rb:118:13:118:13 | 5 | 5 | int | +| operations/operations.rb:119:14:119:14 | 6 | 6 | int | +| operations/operations.rb:120:15:120:15 | 7 | 7 | int | +| operations/operations.rb:121:25:121:25 | 8 | 8 | int | +| operations/operations.rb:122:5:122:5 | 1 | 1 | int | +| operations/operations.rb:122:31:122:31 | 7 | 7 | int | +| operations/operations.rb:123:17:123:17 | 7 | 7 | int | +| operations/operations.rb:124:1:124:3 | 0 | 0 | int | +| operations/operations.rb:124:6:124:10 | 1 | 1 | int | +| operations/operations.rb:124:13:124:20 | 2 | 2 | int | +| operations/operations.rb:124:25:124:25 | 1 | 1 | int | +| operations/operations.rb:124:28:124:28 | 2 | 2 | int | +| operations/operations.rb:124:31:124:31 | 3 | 3 | int | +| operations/operations.rb:127:1:127:1 | 5 | 5 | int | | params/params.rb:41:46:41:46 | 7 | 7 | int | | params/params.rb:47:19:47:21 | :bar | :bar | symbol | | params/params.rb:47:24:47:24 | 2 | 2 | int | @@ -1257,6 +1271,19 @@ exprCfgNodeValue | control/conditionals.rb:62:5:62:5 | c | 0 | int | | control/conditionals.rb:67:8:67:8 | b | 0 | int | | control/conditionals.rb:69:5:69:5 | c | 0 | int | +| control/conditionals.rb:73:9:73:9 | b | 0 | int | +| control/conditionals.rb:74:5:74:5 | c | 0 | int | +| control/conditionals.rb:79:8:79:8 | b | 0 | int | +| control/conditionals.rb:81:5:81:5 | c | 0 | int | +| control/conditionals.rb:87:9:87:9 | b | 0 | int | +| control/conditionals.rb:89:5:89:5 | c | 0 | int | +| control/conditionals.rb:103:8:103:8 | b | 0 | int | +| control/conditionals.rb:105:5:105:5 | c | 0 | int | +| control/conditionals.rb:110:8:110:8 | b | 0 | int | +| control/conditionals.rb:111:8:111:8 | c | 0 | int | +| control/conditionals.rb:113:5:113:5 | d | 0 | int | +| control/conditionals.rb:145:5:145:5 | b | 0 | int | +| control/conditionals.rb:147:5:147:5 | c | 0 | int | | control/loops.rb:2:7:2:7 | 0 | 0 | int | | control/loops.rb:3:7:3:7 | 0 | 0 | int | | control/loops.rb:4:5:4:5 | 0 | 0 | int | @@ -1828,26 +1855,27 @@ exprCfgNodeValue | operations/operations.rb:84:9:84:12 | 0x01 | 1 | int | | operations/operations.rb:85:2:85:4 | baz | 0 | int | | operations/operations.rb:85:9:85:11 | qux | 0 | int | -| operations/operations.rb:88:8:88:8 | 1 | 1 | int | -| operations/operations.rb:89:9:89:9 | 2 | 2 | int | -| operations/operations.rb:91:9:91:9 | 3 | 3 | int | -| operations/operations.rb:92:10:92:10 | 4 | 4 | int | -| operations/operations.rb:95:15:95:15 | 5 | 5 | int | -| operations/operations.rb:96:16:96:16 | 6 | 6 | int | -| operations/operations.rb:98:13:98:13 | 5 | 5 | int | -| operations/operations.rb:99:14:99:14 | 6 | 6 | int | -| operations/operations.rb:100:15:100:15 | 7 | 7 | int | -| operations/operations.rb:101:25:101:25 | 8 | 8 | int | -| operations/operations.rb:102:5:102:5 | 1 | 1 | int | -| operations/operations.rb:102:31:102:31 | 7 | 7 | int | -| operations/operations.rb:103:17:103:17 | 7 | 7 | int | -| operations/operations.rb:104:1:104:3 | 0 | 0 | int | -| operations/operations.rb:104:6:104:10 | 1 | 1 | int | -| operations/operations.rb:104:13:104:20 | 2 | 2 | int | -| operations/operations.rb:104:25:104:25 | 1 | 1 | int | -| operations/operations.rb:104:28:104:28 | 2 | 2 | int | -| operations/operations.rb:104:31:104:31 | 3 | 3 | int | -| operations/operations.rb:107:1:107:1 | 5 | 5 | int | +| operations/operations.rb:89:6:89:6 | b | 0 | int | +| operations/operations.rb:108:8:108:8 | 1 | 1 | int | +| operations/operations.rb:109:9:109:9 | 2 | 2 | int | +| operations/operations.rb:111:9:111:9 | 3 | 3 | int | +| operations/operations.rb:112:10:112:10 | 4 | 4 | int | +| operations/operations.rb:115:15:115:15 | 5 | 5 | int | +| operations/operations.rb:116:16:116:16 | 6 | 6 | int | +| operations/operations.rb:118:13:118:13 | 5 | 5 | int | +| operations/operations.rb:119:14:119:14 | 6 | 6 | int | +| operations/operations.rb:120:15:120:15 | 7 | 7 | int | +| operations/operations.rb:121:25:121:25 | 8 | 8 | int | +| operations/operations.rb:122:5:122:5 | 1 | 1 | int | +| operations/operations.rb:122:31:122:31 | 7 | 7 | int | +| operations/operations.rb:123:17:123:17 | 7 | 7 | int | +| operations/operations.rb:124:1:124:3 | 0 | 0 | int | +| operations/operations.rb:124:6:124:10 | 1 | 1 | int | +| operations/operations.rb:124:13:124:20 | 2 | 2 | int | +| operations/operations.rb:124:25:124:25 | 1 | 1 | int | +| operations/operations.rb:124:28:124:28 | 2 | 2 | int | +| operations/operations.rb:124:31:124:31 | 3 | 3 | int | +| operations/operations.rb:127:1:127:1 | 5 | 5 | int | | params/params.rb:41:46:41:46 | 7 | 7 | int | | params/params.rb:47:19:47:21 | :bar | :bar | symbol | | params/params.rb:47:24:47:24 | 2 | 2 | int | diff --git a/ruby/ql/test/library-tests/ast/control/ConditionalExpr.expected b/ruby/ql/test/library-tests/ast/control/ConditionalExpr.expected index db7cd1957fb0..b2817b6feda4 100644 --- a/ruby/ql/test/library-tests/ast/control/ConditionalExpr.expected +++ b/ruby/ql/test/library-tests/ast/control/ConditionalExpr.expected @@ -22,6 +22,12 @@ conditionalExprs | conditionals.rb:61:1:64:3 | if ... | IfExpr | conditionals.rb:61:4:61:8 | ... > ... | conditionals.rb:63:1:63:4 | else ... | false | | conditionals.rb:67:1:70:3 | if ... | IfExpr | conditionals.rb:67:4:67:8 | ... > ... | conditionals.rb:67:10:67:13 | then ... | true | | conditionals.rb:67:1:70:3 | if ... | IfExpr | conditionals.rb:67:4:67:8 | ... > ... | conditionals.rb:68:1:69:5 | else ... | false | +| conditionals.rb:73:1:75:3 | if ... | IfExpr | conditionals.rb:73:4:73:9 | ... && ... | conditionals.rb:73:11:74:5 | then ... | true | +| conditionals.rb:78:1:82:3 | if ... | IfExpr | conditionals.rb:78:4:79:8 | ... && ... | conditionals.rb:79:9:81:5 | then ... | true | +| conditionals.rb:86:1:90:3 | if ... | IfExpr | conditionals.rb:86:4:86:4 | a | conditionals.rb:86:5:89:5 | then ... | true | +| conditionals.rb:102:1:106:3 | if ... | IfExpr | conditionals.rb:102:4:102:4 | a | conditionals.rb:102:5:105:5 | then ... | true | +| conditionals.rb:109:1:114:3 | if ... | IfExpr | conditionals.rb:109:4:111:8 | ... && ... | conditionals.rb:111:9:113:5 | then ... | true | +| conditionals.rb:144:1:148:3 | if ... | IfExpr | conditionals.rb:144:4:145:5 | ... && ... | conditionals.rb:145:6:147:5 | then ... | true | | loops.rb:9:5:9:5 | if ... | IfExpr | loops.rb:9:5:9:5 | ! ... | loops.rb:9:5:9:5 | ... = ... | true | | loops.rb:16:5:16:5 | if ... | IfExpr | loops.rb:16:5:16:5 | ! ... | loops.rb:16:5:16:5 | ... = ... | true | | loops.rb:22:5:22:7 | if ... | IfExpr | loops.rb:22:5:22:7 | ! ... | loops.rb:22:5:22:7 | ... = ... | true | @@ -38,6 +44,12 @@ ifExprs | conditionals.rb:35:1:36:5 | elsif ... | IfExpr | conditionals.rb:35:7:35:12 | ... == ... | conditionals.rb:35:13:36:5 | then ... | (none) | true | | conditionals.rb:61:1:64:3 | if ... | IfExpr | conditionals.rb:61:4:61:8 | ... > ... | conditionals.rb:61:10:62:5 | then ... | else ... | false | | conditionals.rb:67:1:70:3 | if ... | IfExpr | conditionals.rb:67:4:67:8 | ... > ... | conditionals.rb:67:10:67:13 | then ... | else ... | false | +| conditionals.rb:73:1:75:3 | if ... | IfExpr | conditionals.rb:73:4:73:9 | ... && ... | conditionals.rb:73:11:74:5 | then ... | (none) | false | +| conditionals.rb:78:1:82:3 | if ... | IfExpr | conditionals.rb:78:4:79:8 | ... && ... | conditionals.rb:79:9:81:5 | then ... | (none) | false | +| conditionals.rb:86:1:90:3 | if ... | IfExpr | conditionals.rb:86:4:86:4 | a | conditionals.rb:86:5:89:5 | then ... | (none) | false | +| conditionals.rb:102:1:106:3 | if ... | IfExpr | conditionals.rb:102:4:102:4 | a | conditionals.rb:102:5:105:5 | then ... | (none) | false | +| conditionals.rb:109:1:114:3 | if ... | IfExpr | conditionals.rb:109:4:111:8 | ... && ... | conditionals.rb:111:9:113:5 | then ... | (none) | false | +| conditionals.rb:144:1:148:3 | if ... | IfExpr | conditionals.rb:144:4:145:5 | ... && ... | conditionals.rb:145:6:147:5 | then ... | (none) | false | unlessExprs | conditionals.rb:40:1:42:3 | unless ... | UnlessExpr | conditionals.rb:40:8:40:12 | ... > ... | conditionals.rb:40:14:41:5 | then ... | (none) | | conditionals.rb:45:1:49:3 | unless ... | UnlessExpr | conditionals.rb:45:8:45:13 | ... == ... | conditionals.rb:45:14:46:5 | then ... | else ... | diff --git a/ruby/ql/test/library-tests/ast/control/ControlExpr.expected b/ruby/ql/test/library-tests/ast/control/ControlExpr.expected index aaa72ac80277..e84d2608249f 100644 --- a/ruby/ql/test/library-tests/ast/control/ControlExpr.expected +++ b/ruby/ql/test/library-tests/ast/control/ControlExpr.expected @@ -28,6 +28,12 @@ | conditionals.rb:58:5:58:25 | ... ? ... : ... | TernaryIfExpr | | conditionals.rb:61:1:64:3 | if ... | IfExpr | | conditionals.rb:67:1:70:3 | if ... | IfExpr | +| conditionals.rb:73:1:75:3 | if ... | IfExpr | +| conditionals.rb:78:1:82:3 | if ... | IfExpr | +| conditionals.rb:86:1:90:3 | if ... | IfExpr | +| conditionals.rb:102:1:106:3 | if ... | IfExpr | +| conditionals.rb:109:1:114:3 | if ... | IfExpr | +| conditionals.rb:144:1:148:3 | if ... | IfExpr | | loops.rb:9:1:12:3 | for ... in ... | ForExpr | | loops.rb:9:5:9:5 | if ... | IfExpr | | loops.rb:16:1:19:3 | for ... in ... | ForExpr | diff --git a/ruby/ql/test/library-tests/ast/control/conditionals.rb b/ruby/ql/test/library-tests/ast/control/conditionals.rb index 85e008f5c1d5..b5c63afbc81c 100644 --- a/ruby/ql/test/library-tests/ast/control/conditionals.rb +++ b/ruby/ql/test/library-tests/ast/control/conditionals.rb @@ -67,4 +67,82 @@ if a > b then else c +end + +# If expr with `&&` on same line as condition and then +if a && b then + c +end + +# If expr with `&&` at the start of a separate line before then +if a + && b +then + c +end + +# If expr with `and` at the start of a separate line before then +# NOTE: This is not parsed correctly, `and b` is parsed as a call +if a + and b +then + c +end + +# If expr with `||` at the start of a separate line before then +# NOTE: This is not parsed correctly due to the leading `||` +# if a +# || b +# then +# c +# end + +# If expr with `or` at the start of a separate line before then +# NOTE: This is not parsed correctly, `or b` is parsed as a call +if a + or b +then + c +end + +# If expr with repeated && at the start of a separate line before then +if a + && b + && c +then + d +end + +# If expr with alternating && and || at the start of lines +# NOTE: This is not parsed correctly due to the leading `||` +# if a +# && b +# || c +# then +# d +# end + +# If expr with operator at start of line and parentheses +# NOTE: This is not parsed correctly due to the leading `||` +# if a +# && (b +# || c) +# then +# d +# end + +# If expr with operator at start of line and parentheses +# NOTE: This is not parsed correctly due to the leading `||` +# if a +# || (b +# && c) +# then +# d +# end + +# If expr with && at end of line +if a && + b +then + c end \ No newline at end of file diff --git a/ruby/ql/test/library-tests/ast/operations/assignment.expected b/ruby/ql/test/library-tests/ast/operations/assignment.expected index 5349ebf5cef6..54f6a0c00fa5 100644 --- a/ruby/ql/test/library-tests/ast/operations/assignment.expected +++ b/ruby/ql/test/library-tests/ast/operations/assignment.expected @@ -43,34 +43,35 @@ assignments | operations.rb:84:2:84:12 | ... \|= ... | \|= | operations.rb:84:2:84:4 | bar | operations.rb:84:9:84:12 | 0x01 | AssignBitwiseOrExpr | | operations.rb:85:2:85:11 | ... = ... | = | operations.rb:85:2:85:4 | baz | operations.rb:85:6:85:7 | ... ^ ... | AssignExpr | | operations.rb:85:2:85:11 | ... ^= ... | ^= | operations.rb:85:2:85:4 | baz | operations.rb:85:9:85:11 | qux | AssignBitwiseXorExpr | -| operations.rb:88:3:88:8 | ... = ... | = | operations.rb:88:3:88:4 | @x | operations.rb:88:8:88:8 | 1 | AssignExpr | -| operations.rb:89:3:89:9 | ... += ... | += | operations.rb:89:3:89:4 | @x | operations.rb:89:9:89:9 | 2 | AssignAddExpr | -| operations.rb:89:3:89:9 | ... = ... | = | operations.rb:89:3:89:4 | @x | operations.rb:89:6:89:7 | ... + ... | AssignExpr | -| operations.rb:91:3:91:9 | ... = ... | = | operations.rb:91:3:91:5 | @@y | operations.rb:91:9:91:9 | 3 | AssignExpr | -| operations.rb:92:3:92:10 | ... /= ... | /= | operations.rb:92:3:92:5 | @@y | operations.rb:92:10:92:10 | 4 | AssignDivExpr | -| operations.rb:92:3:92:10 | ... = ... | = | operations.rb:92:3:92:5 | @@y | operations.rb:92:7:92:8 | ... / ... | AssignExpr | -| operations.rb:95:1:95:15 | ... = ... | = | operations.rb:95:1:95:11 | $global_var | operations.rb:95:15:95:15 | 5 | AssignExpr | -| operations.rb:96:1:96:16 | ... *= ... | *= | operations.rb:96:1:96:11 | $global_var | operations.rb:96:16:96:16 | 6 | AssignMulExpr | -| operations.rb:96:1:96:16 | ... = ... | = | operations.rb:96:1:96:11 | $global_var | operations.rb:96:13:96:14 | ... * ... | AssignExpr | -| operations.rb:98:1:98:13 | ... = ... | = | operations.rb:98:1:98:9 | CONSTANT1 | operations.rb:98:13:98:13 | 5 | AssignExpr | -| operations.rb:99:1:99:14 | ... += ... | += | operations.rb:99:1:99:9 | CONSTANT2 | operations.rb:99:14:99:14 | 6 | AssignAddExpr | -| operations.rb:99:1:99:14 | ... = ... | = | operations.rb:99:1:99:9 | CONSTANT2 | operations.rb:99:11:99:12 | ... + ... | AssignExpr | -| operations.rb:100:1:100:15 | ... = ... | = | operations.rb:100:1:100:9 | CONSTANT3 | operations.rb:100:11:100:13 | ... \|\| ... | AssignExpr | -| operations.rb:100:1:100:15 | ... \|\|= ... | \|\|= | operations.rb:100:1:100:9 | CONSTANT3 | operations.rb:100:15:100:15 | 7 | AssignLogicalOrExpr | -| operations.rb:101:1:101:3 | ... = ... | = | operations.rb:101:1:101:3 | __synth__0 | operations.rb:101:1:101:3 | Foo | AssignExpr | -| operations.rb:101:1:101:25 | ... = ... | = | operations.rb:101:1:101:19 | MemberConstant | operations.rb:101:21:101:23 | ... \|\| ... | AssignExpr | -| operations.rb:101:1:101:25 | ... \|\|= ... | \|\|= | operations.rb:101:1:101:19 | MemberConstant | operations.rb:101:25:101:25 | 8 | AssignLogicalOrExpr | -| operations.rb:102:1:102:10 | ... = ... | = | operations.rb:102:1:102:10 | __synth__0 | operations.rb:102:1:102:10 | call to bar | AssignExpr | -| operations.rb:102:1:102:31 | ... = ... | = | operations.rb:102:1:102:25 | OtherConstant | operations.rb:102:27:102:29 | ... \|\| ... | AssignExpr | -| operations.rb:102:1:102:31 | ... \|\|= ... | \|\|= | operations.rb:102:1:102:25 | OtherConstant | operations.rb:102:31:102:31 | 7 | AssignLogicalOrExpr | -| operations.rb:103:1:103:17 | ... = ... | = | operations.rb:103:1:103:11 | CONSTANT4 | operations.rb:103:13:103:15 | ... \|\| ... | AssignExpr | -| operations.rb:103:1:103:17 | ... \|\|= ... | \|\|= | operations.rb:103:1:103:11 | CONSTANT4 | operations.rb:103:17:103:17 | 7 | AssignLogicalOrExpr | -| operations.rb:104:1:104:3 | ... = ... | = | operations.rb:104:1:104:3 | FOO | operations.rb:104:1:104:3 | call to [] | AssignExpr | -| operations.rb:104:1:104:32 | ... = ... | = | operations.rb:104:1:104:20 | (..., ...) | operations.rb:104:24:104:32 | [...] | AssignExpr | -| operations.rb:104:6:104:10 | ... = ... | = | operations.rb:104:6:104:10 | BAR | operations.rb:104:6:104:10 | call to [] | AssignExpr | -| operations.rb:104:13:104:15 | ... = ... | = | operations.rb:104:13:104:15 | __synth__2 | operations.rb:104:13:104:15 | foo | AssignExpr | -| operations.rb:104:13:104:20 | ... = ... | = | operations.rb:104:13:104:20 | FOO | operations.rb:104:13:104:20 | call to [] | AssignExpr | -| operations.rb:104:24:104:32 | ... = ... | = | operations.rb:104:24:104:32 | __synth__3 | operations.rb:104:24:104:32 | * ... | AssignExpr | +| operations.rb:88:1:89:6 | ... = ... | = | operations.rb:88:1:88:3 | foo | operations.rb:88:7:89:6 | ... && ... | AssignExpr | +| operations.rb:108:3:108:8 | ... = ... | = | operations.rb:108:3:108:4 | @x | operations.rb:108:8:108:8 | 1 | AssignExpr | +| operations.rb:109:3:109:9 | ... += ... | += | operations.rb:109:3:109:4 | @x | operations.rb:109:9:109:9 | 2 | AssignAddExpr | +| operations.rb:109:3:109:9 | ... = ... | = | operations.rb:109:3:109:4 | @x | operations.rb:109:6:109:7 | ... + ... | AssignExpr | +| operations.rb:111:3:111:9 | ... = ... | = | operations.rb:111:3:111:5 | @@y | operations.rb:111:9:111:9 | 3 | AssignExpr | +| operations.rb:112:3:112:10 | ... /= ... | /= | operations.rb:112:3:112:5 | @@y | operations.rb:112:10:112:10 | 4 | AssignDivExpr | +| operations.rb:112:3:112:10 | ... = ... | = | operations.rb:112:3:112:5 | @@y | operations.rb:112:7:112:8 | ... / ... | AssignExpr | +| operations.rb:115:1:115:15 | ... = ... | = | operations.rb:115:1:115:11 | $global_var | operations.rb:115:15:115:15 | 5 | AssignExpr | +| operations.rb:116:1:116:16 | ... *= ... | *= | operations.rb:116:1:116:11 | $global_var | operations.rb:116:16:116:16 | 6 | AssignMulExpr | +| operations.rb:116:1:116:16 | ... = ... | = | operations.rb:116:1:116:11 | $global_var | operations.rb:116:13:116:14 | ... * ... | AssignExpr | +| operations.rb:118:1:118:13 | ... = ... | = | operations.rb:118:1:118:9 | CONSTANT1 | operations.rb:118:13:118:13 | 5 | AssignExpr | +| operations.rb:119:1:119:14 | ... += ... | += | operations.rb:119:1:119:9 | CONSTANT2 | operations.rb:119:14:119:14 | 6 | AssignAddExpr | +| operations.rb:119:1:119:14 | ... = ... | = | operations.rb:119:1:119:9 | CONSTANT2 | operations.rb:119:11:119:12 | ... + ... | AssignExpr | +| operations.rb:120:1:120:15 | ... = ... | = | operations.rb:120:1:120:9 | CONSTANT3 | operations.rb:120:11:120:13 | ... \|\| ... | AssignExpr | +| operations.rb:120:1:120:15 | ... \|\|= ... | \|\|= | operations.rb:120:1:120:9 | CONSTANT3 | operations.rb:120:15:120:15 | 7 | AssignLogicalOrExpr | +| operations.rb:121:1:121:3 | ... = ... | = | operations.rb:121:1:121:3 | __synth__0 | operations.rb:121:1:121:3 | Foo | AssignExpr | +| operations.rb:121:1:121:25 | ... = ... | = | operations.rb:121:1:121:19 | MemberConstant | operations.rb:121:21:121:23 | ... \|\| ... | AssignExpr | +| operations.rb:121:1:121:25 | ... \|\|= ... | \|\|= | operations.rb:121:1:121:19 | MemberConstant | operations.rb:121:25:121:25 | 8 | AssignLogicalOrExpr | +| operations.rb:122:1:122:10 | ... = ... | = | operations.rb:122:1:122:10 | __synth__0 | operations.rb:122:1:122:10 | call to bar | AssignExpr | +| operations.rb:122:1:122:31 | ... = ... | = | operations.rb:122:1:122:25 | OtherConstant | operations.rb:122:27:122:29 | ... \|\| ... | AssignExpr | +| operations.rb:122:1:122:31 | ... \|\|= ... | \|\|= | operations.rb:122:1:122:25 | OtherConstant | operations.rb:122:31:122:31 | 7 | AssignLogicalOrExpr | +| operations.rb:123:1:123:17 | ... = ... | = | operations.rb:123:1:123:11 | CONSTANT4 | operations.rb:123:13:123:15 | ... \|\| ... | AssignExpr | +| operations.rb:123:1:123:17 | ... \|\|= ... | \|\|= | operations.rb:123:1:123:11 | CONSTANT4 | operations.rb:123:17:123:17 | 7 | AssignLogicalOrExpr | +| operations.rb:124:1:124:3 | ... = ... | = | operations.rb:124:1:124:3 | FOO | operations.rb:124:1:124:3 | call to [] | AssignExpr | +| operations.rb:124:1:124:32 | ... = ... | = | operations.rb:124:1:124:20 | (..., ...) | operations.rb:124:24:124:32 | [...] | AssignExpr | +| operations.rb:124:6:124:10 | ... = ... | = | operations.rb:124:6:124:10 | BAR | operations.rb:124:6:124:10 | call to [] | AssignExpr | +| operations.rb:124:13:124:15 | ... = ... | = | operations.rb:124:13:124:15 | __synth__2 | operations.rb:124:13:124:15 | foo | AssignExpr | +| operations.rb:124:13:124:20 | ... = ... | = | operations.rb:124:13:124:20 | FOO | operations.rb:124:13:124:20 | call to [] | AssignExpr | +| operations.rb:124:24:124:32 | ... = ... | = | operations.rb:124:24:124:32 | __synth__3 | operations.rb:124:24:124:32 | * ... | AssignExpr | assignOperations | operations.rb:69:1:69:8 | ... += ... | += | operations.rb:69:1:69:1 | x | operations.rb:69:6:69:8 | 128 | AssignAddExpr | | operations.rb:70:1:70:7 | ... -= ... | -= | operations.rb:70:1:70:1 | y | operations.rb:70:6:70:7 | 32 | AssignSubExpr | @@ -85,14 +86,14 @@ assignOperations | operations.rb:83:2:83:12 | ... &= ... | &= | operations.rb:83:2:83:4 | foo | operations.rb:83:9:83:12 | mask | AssignBitwiseAndExpr | | operations.rb:84:2:84:12 | ... \|= ... | \|= | operations.rb:84:2:84:4 | bar | operations.rb:84:9:84:12 | 0x01 | AssignBitwiseOrExpr | | operations.rb:85:2:85:11 | ... ^= ... | ^= | operations.rb:85:2:85:4 | baz | operations.rb:85:9:85:11 | qux | AssignBitwiseXorExpr | -| operations.rb:89:3:89:9 | ... += ... | += | operations.rb:89:3:89:4 | @x | operations.rb:89:9:89:9 | 2 | AssignAddExpr | -| operations.rb:92:3:92:10 | ... /= ... | /= | operations.rb:92:3:92:5 | @@y | operations.rb:92:10:92:10 | 4 | AssignDivExpr | -| operations.rb:96:1:96:16 | ... *= ... | *= | operations.rb:96:1:96:11 | $global_var | operations.rb:96:16:96:16 | 6 | AssignMulExpr | -| operations.rb:99:1:99:14 | ... += ... | += | operations.rb:99:1:99:9 | CONSTANT2 | operations.rb:99:14:99:14 | 6 | AssignAddExpr | -| operations.rb:100:1:100:15 | ... \|\|= ... | \|\|= | operations.rb:100:1:100:9 | CONSTANT3 | operations.rb:100:15:100:15 | 7 | AssignLogicalOrExpr | -| operations.rb:101:1:101:25 | ... \|\|= ... | \|\|= | operations.rb:101:1:101:19 | MemberConstant | operations.rb:101:25:101:25 | 8 | AssignLogicalOrExpr | -| operations.rb:102:1:102:31 | ... \|\|= ... | \|\|= | operations.rb:102:1:102:25 | OtherConstant | operations.rb:102:31:102:31 | 7 | AssignLogicalOrExpr | -| operations.rb:103:1:103:17 | ... \|\|= ... | \|\|= | operations.rb:103:1:103:11 | CONSTANT4 | operations.rb:103:17:103:17 | 7 | AssignLogicalOrExpr | +| operations.rb:109:3:109:9 | ... += ... | += | operations.rb:109:3:109:4 | @x | operations.rb:109:9:109:9 | 2 | AssignAddExpr | +| operations.rb:112:3:112:10 | ... /= ... | /= | operations.rb:112:3:112:5 | @@y | operations.rb:112:10:112:10 | 4 | AssignDivExpr | +| operations.rb:116:1:116:16 | ... *= ... | *= | operations.rb:116:1:116:11 | $global_var | operations.rb:116:16:116:16 | 6 | AssignMulExpr | +| operations.rb:119:1:119:14 | ... += ... | += | operations.rb:119:1:119:9 | CONSTANT2 | operations.rb:119:14:119:14 | 6 | AssignAddExpr | +| operations.rb:120:1:120:15 | ... \|\|= ... | \|\|= | operations.rb:120:1:120:9 | CONSTANT3 | operations.rb:120:15:120:15 | 7 | AssignLogicalOrExpr | +| operations.rb:121:1:121:25 | ... \|\|= ... | \|\|= | operations.rb:121:1:121:19 | MemberConstant | operations.rb:121:25:121:25 | 8 | AssignLogicalOrExpr | +| operations.rb:122:1:122:31 | ... \|\|= ... | \|\|= | operations.rb:122:1:122:25 | OtherConstant | operations.rb:122:31:122:31 | 7 | AssignLogicalOrExpr | +| operations.rb:123:1:123:17 | ... \|\|= ... | \|\|= | operations.rb:123:1:123:11 | CONSTANT4 | operations.rb:123:17:123:17 | 7 | AssignLogicalOrExpr | assignArithmeticOperations | operations.rb:69:1:69:8 | ... += ... | += | operations.rb:69:1:69:1 | x | operations.rb:69:6:69:8 | 128 | AssignAddExpr | | operations.rb:70:1:70:7 | ... -= ... | -= | operations.rb:70:1:70:1 | y | operations.rb:70:6:70:7 | 32 | AssignSubExpr | @@ -100,17 +101,17 @@ assignArithmeticOperations | operations.rb:72:1:72:6 | ... /= ... | /= | operations.rb:72:1:72:1 | b | operations.rb:72:6:72:6 | 4 | AssignDivExpr | | operations.rb:73:1:73:6 | ... %= ... | %= | operations.rb:73:1:73:1 | z | operations.rb:73:6:73:6 | 2 | AssignModuloExpr | | operations.rb:74:1:74:11 | ... **= ... | **= | operations.rb:74:1:74:3 | foo | operations.rb:74:9:74:11 | bar | AssignExponentExpr | -| operations.rb:89:3:89:9 | ... += ... | += | operations.rb:89:3:89:4 | @x | operations.rb:89:9:89:9 | 2 | AssignAddExpr | -| operations.rb:92:3:92:10 | ... /= ... | /= | operations.rb:92:3:92:5 | @@y | operations.rb:92:10:92:10 | 4 | AssignDivExpr | -| operations.rb:96:1:96:16 | ... *= ... | *= | operations.rb:96:1:96:11 | $global_var | operations.rb:96:16:96:16 | 6 | AssignMulExpr | -| operations.rb:99:1:99:14 | ... += ... | += | operations.rb:99:1:99:9 | CONSTANT2 | operations.rb:99:14:99:14 | 6 | AssignAddExpr | +| operations.rb:109:3:109:9 | ... += ... | += | operations.rb:109:3:109:4 | @x | operations.rb:109:9:109:9 | 2 | AssignAddExpr | +| operations.rb:112:3:112:10 | ... /= ... | /= | operations.rb:112:3:112:5 | @@y | operations.rb:112:10:112:10 | 4 | AssignDivExpr | +| operations.rb:116:1:116:16 | ... *= ... | *= | operations.rb:116:1:116:11 | $global_var | operations.rb:116:16:116:16 | 6 | AssignMulExpr | +| operations.rb:119:1:119:14 | ... += ... | += | operations.rb:119:1:119:9 | CONSTANT2 | operations.rb:119:14:119:14 | 6 | AssignAddExpr | assignLogicalOperations | operations.rb:77:2:77:8 | ... &&= ... | &&= | operations.rb:77:2:77:2 | x | operations.rb:77:8:77:8 | y | AssignLogicalAndExpr | | operations.rb:78:2:78:8 | ... \|\|= ... | \|\|= | operations.rb:78:2:78:2 | a | operations.rb:78:8:78:8 | b | AssignLogicalOrExpr | -| operations.rb:100:1:100:15 | ... \|\|= ... | \|\|= | operations.rb:100:1:100:9 | CONSTANT3 | operations.rb:100:15:100:15 | 7 | AssignLogicalOrExpr | -| operations.rb:101:1:101:25 | ... \|\|= ... | \|\|= | operations.rb:101:1:101:19 | MemberConstant | operations.rb:101:25:101:25 | 8 | AssignLogicalOrExpr | -| operations.rb:102:1:102:31 | ... \|\|= ... | \|\|= | operations.rb:102:1:102:25 | OtherConstant | operations.rb:102:31:102:31 | 7 | AssignLogicalOrExpr | -| operations.rb:103:1:103:17 | ... \|\|= ... | \|\|= | operations.rb:103:1:103:11 | CONSTANT4 | operations.rb:103:17:103:17 | 7 | AssignLogicalOrExpr | +| operations.rb:120:1:120:15 | ... \|\|= ... | \|\|= | operations.rb:120:1:120:9 | CONSTANT3 | operations.rb:120:15:120:15 | 7 | AssignLogicalOrExpr | +| operations.rb:121:1:121:25 | ... \|\|= ... | \|\|= | operations.rb:121:1:121:19 | MemberConstant | operations.rb:121:25:121:25 | 8 | AssignLogicalOrExpr | +| operations.rb:122:1:122:31 | ... \|\|= ... | \|\|= | operations.rb:122:1:122:25 | OtherConstant | operations.rb:122:31:122:31 | 7 | AssignLogicalOrExpr | +| operations.rb:123:1:123:17 | ... \|\|= ... | \|\|= | operations.rb:123:1:123:11 | CONSTANT4 | operations.rb:123:17:123:17 | 7 | AssignLogicalOrExpr | assignBitwiseOperations | operations.rb:81:2:81:8 | ... <<= ... | <<= | operations.rb:81:2:81:2 | x | operations.rb:81:8:81:8 | 2 | AssignLShiftExpr | | operations.rb:82:2:82:8 | ... >>= ... | >>= | operations.rb:82:2:82:2 | y | operations.rb:82:8:82:8 | 3 | AssignRShiftExpr | diff --git a/ruby/ql/test/library-tests/ast/operations/binary.expected b/ruby/ql/test/library-tests/ast/operations/binary.expected index 2b632384663d..3f29a82a2c49 100644 --- a/ruby/ql/test/library-tests/ast/operations/binary.expected +++ b/ruby/ql/test/library-tests/ast/operations/binary.expected @@ -37,15 +37,17 @@ binaryOperations | operations.rb:83:6:83:7 | ... & ... | & | operations.rb:83:2:83:4 | foo | operations.rb:83:9:83:12 | mask | BitwiseAndExpr | | operations.rb:84:6:84:7 | ... \| ... | \| | operations.rb:84:2:84:4 | bar | operations.rb:84:9:84:12 | 0x01 | BitwiseOrExpr | | operations.rb:85:6:85:7 | ... ^ ... | ^ | operations.rb:85:2:85:4 | baz | operations.rb:85:9:85:11 | qux | BitwiseXorExpr | -| operations.rb:89:6:89:7 | ... + ... | + | operations.rb:89:3:89:4 | @x | operations.rb:89:9:89:9 | 2 | AddExpr | -| operations.rb:92:7:92:8 | ... / ... | / | operations.rb:92:3:92:5 | @@y | operations.rb:92:10:92:10 | 4 | DivExpr | -| operations.rb:96:13:96:14 | ... * ... | * | operations.rb:96:1:96:11 | $global_var | operations.rb:96:16:96:16 | 6 | MulExpr | -| operations.rb:99:11:99:12 | ... + ... | + | operations.rb:99:1:99:9 | CONSTANT2 | operations.rb:99:14:99:14 | 6 | AddExpr | -| operations.rb:100:11:100:13 | ... \|\| ... | \|\| | operations.rb:100:1:100:9 | CONSTANT3 | operations.rb:100:15:100:15 | 7 | LogicalOrExpr | -| operations.rb:101:21:101:23 | ... \|\| ... | \|\| | operations.rb:101:1:101:19 | MemberConstant | operations.rb:101:25:101:25 | 8 | LogicalOrExpr | -| operations.rb:102:27:102:29 | ... \|\| ... | \|\| | operations.rb:102:1:102:25 | OtherConstant | operations.rb:102:31:102:31 | 7 | LogicalOrExpr | -| operations.rb:103:13:103:15 | ... \|\| ... | \|\| | operations.rb:103:1:103:11 | CONSTANT4 | operations.rb:103:17:103:17 | 7 | LogicalOrExpr | -| operations.rb:106:1:107:1 | ... / ... | / | operations.rb:106:1:106:3 | foo | operations.rb:107:1:107:1 | 5 | DivExpr | +| operations.rb:88:7:89:6 | ... && ... | && | operations.rb:88:7:88:7 | a | operations.rb:89:6:89:6 | b | LogicalAndExpr | +| operations.rb:96:10:97:8 | ... && ... | && | operations.rb:96:10:96:10 | a | operations.rb:97:8:97:8 | b | LogicalAndExpr | +| operations.rb:109:6:109:7 | ... + ... | + | operations.rb:109:3:109:4 | @x | operations.rb:109:9:109:9 | 2 | AddExpr | +| operations.rb:112:7:112:8 | ... / ... | / | operations.rb:112:3:112:5 | @@y | operations.rb:112:10:112:10 | 4 | DivExpr | +| operations.rb:116:13:116:14 | ... * ... | * | operations.rb:116:1:116:11 | $global_var | operations.rb:116:16:116:16 | 6 | MulExpr | +| operations.rb:119:11:119:12 | ... + ... | + | operations.rb:119:1:119:9 | CONSTANT2 | operations.rb:119:14:119:14 | 6 | AddExpr | +| operations.rb:120:11:120:13 | ... \|\| ... | \|\| | operations.rb:120:1:120:9 | CONSTANT3 | operations.rb:120:15:120:15 | 7 | LogicalOrExpr | +| operations.rb:121:21:121:23 | ... \|\| ... | \|\| | operations.rb:121:1:121:19 | MemberConstant | operations.rb:121:25:121:25 | 8 | LogicalOrExpr | +| operations.rb:122:27:122:29 | ... \|\| ... | \|\| | operations.rb:122:1:122:25 | OtherConstant | operations.rb:122:31:122:31 | 7 | LogicalOrExpr | +| operations.rb:123:13:123:15 | ... \|\| ... | \|\| | operations.rb:123:1:123:11 | CONSTANT4 | operations.rb:123:17:123:17 | 7 | LogicalOrExpr | +| operations.rb:126:1:127:1 | ... / ... | / | operations.rb:126:1:126:3 | foo | operations.rb:127:1:127:1 | 5 | DivExpr | binaryArithmeticOperations | operations.rb:32:1:32:7 | ... + ... | + | operations.rb:32:1:32:1 | w | operations.rb:32:5:32:7 | 234 | AddExpr | | operations.rb:33:1:33:6 | ... - ... | - | operations.rb:33:1:33:1 | x | operations.rb:33:5:33:6 | 17 | SubExpr | @@ -59,11 +61,11 @@ binaryArithmeticOperations | operations.rb:72:3:72:4 | ... / ... | / | operations.rb:72:1:72:1 | b | operations.rb:72:6:72:6 | 4 | DivExpr | | operations.rb:73:3:73:4 | ... % ... | % | operations.rb:73:1:73:1 | z | operations.rb:73:6:73:6 | 2 | ModuloExpr | | operations.rb:74:5:74:7 | ... ** ... | ** | operations.rb:74:1:74:3 | foo | operations.rb:74:9:74:11 | bar | ExponentExpr | -| operations.rb:89:6:89:7 | ... + ... | + | operations.rb:89:3:89:4 | @x | operations.rb:89:9:89:9 | 2 | AddExpr | -| operations.rb:92:7:92:8 | ... / ... | / | operations.rb:92:3:92:5 | @@y | operations.rb:92:10:92:10 | 4 | DivExpr | -| operations.rb:96:13:96:14 | ... * ... | * | operations.rb:96:1:96:11 | $global_var | operations.rb:96:16:96:16 | 6 | MulExpr | -| operations.rb:99:11:99:12 | ... + ... | + | operations.rb:99:1:99:9 | CONSTANT2 | operations.rb:99:14:99:14 | 6 | AddExpr | -| operations.rb:106:1:107:1 | ... / ... | / | operations.rb:106:1:106:3 | foo | operations.rb:107:1:107:1 | 5 | DivExpr | +| operations.rb:109:6:109:7 | ... + ... | + | operations.rb:109:3:109:4 | @x | operations.rb:109:9:109:9 | 2 | AddExpr | +| operations.rb:112:7:112:8 | ... / ... | / | operations.rb:112:3:112:5 | @@y | operations.rb:112:10:112:10 | 4 | DivExpr | +| operations.rb:116:13:116:14 | ... * ... | * | operations.rb:116:1:116:11 | $global_var | operations.rb:116:16:116:16 | 6 | MulExpr | +| operations.rb:119:11:119:12 | ... + ... | + | operations.rb:119:1:119:9 | CONSTANT2 | operations.rb:119:14:119:14 | 6 | AddExpr | +| operations.rb:126:1:127:1 | ... / ... | / | operations.rb:126:1:126:3 | foo | operations.rb:127:1:127:1 | 5 | DivExpr | binaryLogicalOperations | operations.rb:40:1:40:10 | ... && ... | && | operations.rb:40:1:40:3 | foo | operations.rb:40:8:40:10 | bar | LogicalAndExpr | | operations.rb:41:1:41:11 | ... and ... | and | operations.rb:41:1:41:3 | baz | operations.rb:41:9:41:11 | qux | LogicalAndExpr | @@ -71,10 +73,12 @@ binaryLogicalOperations | operations.rb:43:1:43:6 | ... \|\| ... | \|\| | operations.rb:43:1:43:1 | x | operations.rb:43:6:43:6 | y | LogicalOrExpr | | operations.rb:77:4:77:6 | ... && ... | && | operations.rb:77:2:77:2 | x | operations.rb:77:8:77:8 | y | LogicalAndExpr | | operations.rb:78:4:78:6 | ... \|\| ... | \|\| | operations.rb:78:2:78:2 | a | operations.rb:78:8:78:8 | b | LogicalOrExpr | -| operations.rb:100:11:100:13 | ... \|\| ... | \|\| | operations.rb:100:1:100:9 | CONSTANT3 | operations.rb:100:15:100:15 | 7 | LogicalOrExpr | -| operations.rb:101:21:101:23 | ... \|\| ... | \|\| | operations.rb:101:1:101:19 | MemberConstant | operations.rb:101:25:101:25 | 8 | LogicalOrExpr | -| operations.rb:102:27:102:29 | ... \|\| ... | \|\| | operations.rb:102:1:102:25 | OtherConstant | operations.rb:102:31:102:31 | 7 | LogicalOrExpr | -| operations.rb:103:13:103:15 | ... \|\| ... | \|\| | operations.rb:103:1:103:11 | CONSTANT4 | operations.rb:103:17:103:17 | 7 | LogicalOrExpr | +| operations.rb:88:7:89:6 | ... && ... | && | operations.rb:88:7:88:7 | a | operations.rb:89:6:89:6 | b | LogicalAndExpr | +| operations.rb:96:10:97:8 | ... && ... | && | operations.rb:96:10:96:10 | a | operations.rb:97:8:97:8 | b | LogicalAndExpr | +| operations.rb:120:11:120:13 | ... \|\| ... | \|\| | operations.rb:120:1:120:9 | CONSTANT3 | operations.rb:120:15:120:15 | 7 | LogicalOrExpr | +| operations.rb:121:21:121:23 | ... \|\| ... | \|\| | operations.rb:121:1:121:19 | MemberConstant | operations.rb:121:25:121:25 | 8 | LogicalOrExpr | +| operations.rb:122:27:122:29 | ... \|\| ... | \|\| | operations.rb:122:1:122:25 | OtherConstant | operations.rb:122:31:122:31 | 7 | LogicalOrExpr | +| operations.rb:123:13:123:15 | ... \|\| ... | \|\| | operations.rb:123:1:123:11 | CONSTANT4 | operations.rb:123:17:123:17 | 7 | LogicalOrExpr | binaryBitwiseOperations | operations.rb:46:1:46:6 | ... << ... | << | operations.rb:46:1:46:1 | x | operations.rb:46:6:46:6 | 3 | LShiftExpr | | operations.rb:47:1:47:7 | ... >> ... | >> | operations.rb:47:1:47:1 | y | operations.rb:47:6:47:7 | 16 | RShiftExpr | diff --git a/ruby/ql/test/library-tests/ast/operations/operation.expected b/ruby/ql/test/library-tests/ast/operations/operation.expected index 29abf236af69..7f7833f707dd 100644 --- a/ruby/ql/test/library-tests/ast/operations/operation.expected +++ b/ruby/ql/test/library-tests/ast/operations/operation.expected @@ -170,78 +170,84 @@ | operations.rb:85:2:85:11 | ... ^= ... | ^= | operations.rb:85:9:85:11 | qux | AssignBitwiseXorExpr | | operations.rb:85:6:85:7 | ... ^ ... | ^ | operations.rb:85:2:85:4 | baz | BitwiseXorExpr | | operations.rb:85:6:85:7 | ... ^ ... | ^ | operations.rb:85:9:85:11 | qux | BitwiseXorExpr | -| operations.rb:88:3:88:8 | ... = ... | = | operations.rb:88:3:88:4 | @x | AssignExpr | -| operations.rb:88:3:88:8 | ... = ... | = | operations.rb:88:8:88:8 | 1 | AssignExpr | -| operations.rb:89:3:89:9 | ... += ... | += | operations.rb:89:3:89:4 | @x | AssignAddExpr | -| operations.rb:89:3:89:9 | ... += ... | += | operations.rb:89:9:89:9 | 2 | AssignAddExpr | -| operations.rb:89:3:89:9 | ... = ... | = | operations.rb:89:3:89:4 | @x | AssignExpr | -| operations.rb:89:3:89:9 | ... = ... | = | operations.rb:89:6:89:7 | ... + ... | AssignExpr | -| operations.rb:89:6:89:7 | ... + ... | + | operations.rb:89:3:89:4 | @x | AddExpr | -| operations.rb:89:6:89:7 | ... + ... | + | operations.rb:89:9:89:9 | 2 | AddExpr | -| operations.rb:91:3:91:9 | ... = ... | = | operations.rb:91:3:91:5 | @@y | AssignExpr | -| operations.rb:91:3:91:9 | ... = ... | = | operations.rb:91:9:91:9 | 3 | AssignExpr | -| operations.rb:92:3:92:10 | ... /= ... | /= | operations.rb:92:3:92:5 | @@y | AssignDivExpr | -| operations.rb:92:3:92:10 | ... /= ... | /= | operations.rb:92:10:92:10 | 4 | AssignDivExpr | -| operations.rb:92:3:92:10 | ... = ... | = | operations.rb:92:3:92:5 | @@y | AssignExpr | -| operations.rb:92:3:92:10 | ... = ... | = | operations.rb:92:7:92:8 | ... / ... | AssignExpr | -| operations.rb:92:7:92:8 | ... / ... | / | operations.rb:92:3:92:5 | @@y | DivExpr | -| operations.rb:92:7:92:8 | ... / ... | / | operations.rb:92:10:92:10 | 4 | DivExpr | -| operations.rb:95:1:95:15 | ... = ... | = | operations.rb:95:1:95:11 | $global_var | AssignExpr | -| operations.rb:95:1:95:15 | ... = ... | = | operations.rb:95:15:95:15 | 5 | AssignExpr | -| operations.rb:96:1:96:16 | ... *= ... | *= | operations.rb:96:1:96:11 | $global_var | AssignMulExpr | -| operations.rb:96:1:96:16 | ... *= ... | *= | operations.rb:96:16:96:16 | 6 | AssignMulExpr | -| operations.rb:96:1:96:16 | ... = ... | = | operations.rb:96:1:96:11 | $global_var | AssignExpr | -| operations.rb:96:1:96:16 | ... = ... | = | operations.rb:96:13:96:14 | ... * ... | AssignExpr | -| operations.rb:96:13:96:14 | ... * ... | * | operations.rb:96:1:96:11 | $global_var | MulExpr | -| operations.rb:96:13:96:14 | ... * ... | * | operations.rb:96:16:96:16 | 6 | MulExpr | -| operations.rb:98:1:98:13 | ... = ... | = | operations.rb:98:1:98:9 | CONSTANT1 | AssignExpr | -| operations.rb:98:1:98:13 | ... = ... | = | operations.rb:98:13:98:13 | 5 | AssignExpr | -| operations.rb:99:1:99:14 | ... += ... | += | operations.rb:99:1:99:9 | CONSTANT2 | AssignAddExpr | -| operations.rb:99:1:99:14 | ... += ... | += | operations.rb:99:14:99:14 | 6 | AssignAddExpr | -| operations.rb:99:1:99:14 | ... = ... | = | operations.rb:99:1:99:9 | CONSTANT2 | AssignExpr | -| operations.rb:99:1:99:14 | ... = ... | = | operations.rb:99:11:99:12 | ... + ... | AssignExpr | -| operations.rb:99:11:99:12 | ... + ... | + | operations.rb:99:1:99:9 | CONSTANT2 | AddExpr | -| operations.rb:99:11:99:12 | ... + ... | + | operations.rb:99:14:99:14 | 6 | AddExpr | -| operations.rb:100:1:100:15 | ... = ... | = | operations.rb:100:1:100:9 | CONSTANT3 | AssignExpr | -| operations.rb:100:1:100:15 | ... = ... | = | operations.rb:100:11:100:13 | ... \|\| ... | AssignExpr | -| operations.rb:100:1:100:15 | ... \|\|= ... | \|\|= | operations.rb:100:1:100:9 | CONSTANT3 | AssignLogicalOrExpr | -| operations.rb:100:1:100:15 | ... \|\|= ... | \|\|= | operations.rb:100:15:100:15 | 7 | AssignLogicalOrExpr | -| operations.rb:100:11:100:13 | ... \|\| ... | \|\| | operations.rb:100:1:100:9 | CONSTANT3 | LogicalOrExpr | -| operations.rb:100:11:100:13 | ... \|\| ... | \|\| | operations.rb:100:15:100:15 | 7 | LogicalOrExpr | -| operations.rb:101:1:101:3 | ... = ... | = | operations.rb:101:1:101:3 | Foo | AssignExpr | -| operations.rb:101:1:101:3 | ... = ... | = | operations.rb:101:1:101:3 | __synth__0 | AssignExpr | -| operations.rb:101:1:101:25 | ... = ... | = | operations.rb:101:1:101:19 | MemberConstant | AssignExpr | -| operations.rb:101:1:101:25 | ... = ... | = | operations.rb:101:21:101:23 | ... \|\| ... | AssignExpr | -| operations.rb:101:1:101:25 | ... \|\|= ... | \|\|= | operations.rb:101:1:101:19 | MemberConstant | AssignLogicalOrExpr | -| operations.rb:101:1:101:25 | ... \|\|= ... | \|\|= | operations.rb:101:25:101:25 | 8 | AssignLogicalOrExpr | -| operations.rb:101:21:101:23 | ... \|\| ... | \|\| | operations.rb:101:1:101:19 | MemberConstant | LogicalOrExpr | -| operations.rb:101:21:101:23 | ... \|\| ... | \|\| | operations.rb:101:25:101:25 | 8 | LogicalOrExpr | -| operations.rb:102:1:102:10 | ... = ... | = | operations.rb:102:1:102:10 | __synth__0 | AssignExpr | -| operations.rb:102:1:102:10 | ... = ... | = | operations.rb:102:1:102:10 | call to bar | AssignExpr | -| operations.rb:102:1:102:31 | ... = ... | = | operations.rb:102:1:102:25 | OtherConstant | AssignExpr | -| operations.rb:102:1:102:31 | ... = ... | = | operations.rb:102:27:102:29 | ... \|\| ... | AssignExpr | -| operations.rb:102:1:102:31 | ... \|\|= ... | \|\|= | operations.rb:102:1:102:25 | OtherConstant | AssignLogicalOrExpr | -| operations.rb:102:1:102:31 | ... \|\|= ... | \|\|= | operations.rb:102:31:102:31 | 7 | AssignLogicalOrExpr | -| operations.rb:102:27:102:29 | ... \|\| ... | \|\| | operations.rb:102:1:102:25 | OtherConstant | LogicalOrExpr | -| operations.rb:102:27:102:29 | ... \|\| ... | \|\| | operations.rb:102:31:102:31 | 7 | LogicalOrExpr | -| operations.rb:103:1:103:17 | ... = ... | = | operations.rb:103:1:103:11 | CONSTANT4 | AssignExpr | -| operations.rb:103:1:103:17 | ... = ... | = | operations.rb:103:13:103:15 | ... \|\| ... | AssignExpr | -| operations.rb:103:1:103:17 | ... \|\|= ... | \|\|= | operations.rb:103:1:103:11 | CONSTANT4 | AssignLogicalOrExpr | -| operations.rb:103:1:103:17 | ... \|\|= ... | \|\|= | operations.rb:103:17:103:17 | 7 | AssignLogicalOrExpr | -| operations.rb:103:13:103:15 | ... \|\| ... | \|\| | operations.rb:103:1:103:11 | CONSTANT4 | LogicalOrExpr | -| operations.rb:103:13:103:15 | ... \|\| ... | \|\| | operations.rb:103:17:103:17 | 7 | LogicalOrExpr | -| operations.rb:104:1:104:3 | ... = ... | = | operations.rb:104:1:104:3 | FOO | AssignExpr | -| operations.rb:104:1:104:3 | ... = ... | = | operations.rb:104:1:104:3 | call to [] | AssignExpr | -| operations.rb:104:1:104:32 | ... = ... | = | operations.rb:104:1:104:20 | (..., ...) | AssignExpr | -| operations.rb:104:1:104:32 | ... = ... | = | operations.rb:104:24:104:32 | [...] | AssignExpr | -| operations.rb:104:6:104:10 | ... = ... | = | operations.rb:104:6:104:10 | BAR | AssignExpr | -| operations.rb:104:6:104:10 | ... = ... | = | operations.rb:104:6:104:10 | call to [] | AssignExpr | -| operations.rb:104:13:104:15 | ... = ... | = | operations.rb:104:13:104:15 | __synth__2 | AssignExpr | -| operations.rb:104:13:104:15 | ... = ... | = | operations.rb:104:13:104:15 | foo | AssignExpr | -| operations.rb:104:13:104:20 | ... = ... | = | operations.rb:104:13:104:20 | FOO | AssignExpr | -| operations.rb:104:13:104:20 | ... = ... | = | operations.rb:104:13:104:20 | call to [] | AssignExpr | -| operations.rb:104:24:104:32 | * ... | * | operations.rb:104:24:104:32 | [...] | SplatExpr | -| operations.rb:104:24:104:32 | ... = ... | = | operations.rb:104:24:104:32 | * ... | AssignExpr | -| operations.rb:104:24:104:32 | ... = ... | = | operations.rb:104:24:104:32 | __synth__3 | AssignExpr | -| operations.rb:106:1:107:1 | ... / ... | / | operations.rb:106:1:106:3 | foo | DivExpr | -| operations.rb:106:1:107:1 | ... / ... | / | operations.rb:107:1:107:1 | 5 | DivExpr | +| operations.rb:88:1:89:6 | ... = ... | = | operations.rb:88:1:88:3 | foo | AssignExpr | +| operations.rb:88:1:89:6 | ... = ... | = | operations.rb:88:7:89:6 | ... && ... | AssignExpr | +| operations.rb:88:7:89:6 | ... && ... | && | operations.rb:88:7:88:7 | a | LogicalAndExpr | +| operations.rb:88:7:89:6 | ... && ... | && | operations.rb:89:6:89:6 | b | LogicalAndExpr | +| operations.rb:96:10:97:8 | ... && ... | && | operations.rb:96:10:96:10 | a | LogicalAndExpr | +| operations.rb:96:10:97:8 | ... && ... | && | operations.rb:97:8:97:8 | b | LogicalAndExpr | +| operations.rb:108:3:108:8 | ... = ... | = | operations.rb:108:3:108:4 | @x | AssignExpr | +| operations.rb:108:3:108:8 | ... = ... | = | operations.rb:108:8:108:8 | 1 | AssignExpr | +| operations.rb:109:3:109:9 | ... += ... | += | operations.rb:109:3:109:4 | @x | AssignAddExpr | +| operations.rb:109:3:109:9 | ... += ... | += | operations.rb:109:9:109:9 | 2 | AssignAddExpr | +| operations.rb:109:3:109:9 | ... = ... | = | operations.rb:109:3:109:4 | @x | AssignExpr | +| operations.rb:109:3:109:9 | ... = ... | = | operations.rb:109:6:109:7 | ... + ... | AssignExpr | +| operations.rb:109:6:109:7 | ... + ... | + | operations.rb:109:3:109:4 | @x | AddExpr | +| operations.rb:109:6:109:7 | ... + ... | + | operations.rb:109:9:109:9 | 2 | AddExpr | +| operations.rb:111:3:111:9 | ... = ... | = | operations.rb:111:3:111:5 | @@y | AssignExpr | +| operations.rb:111:3:111:9 | ... = ... | = | operations.rb:111:9:111:9 | 3 | AssignExpr | +| operations.rb:112:3:112:10 | ... /= ... | /= | operations.rb:112:3:112:5 | @@y | AssignDivExpr | +| operations.rb:112:3:112:10 | ... /= ... | /= | operations.rb:112:10:112:10 | 4 | AssignDivExpr | +| operations.rb:112:3:112:10 | ... = ... | = | operations.rb:112:3:112:5 | @@y | AssignExpr | +| operations.rb:112:3:112:10 | ... = ... | = | operations.rb:112:7:112:8 | ... / ... | AssignExpr | +| operations.rb:112:7:112:8 | ... / ... | / | operations.rb:112:3:112:5 | @@y | DivExpr | +| operations.rb:112:7:112:8 | ... / ... | / | operations.rb:112:10:112:10 | 4 | DivExpr | +| operations.rb:115:1:115:15 | ... = ... | = | operations.rb:115:1:115:11 | $global_var | AssignExpr | +| operations.rb:115:1:115:15 | ... = ... | = | operations.rb:115:15:115:15 | 5 | AssignExpr | +| operations.rb:116:1:116:16 | ... *= ... | *= | operations.rb:116:1:116:11 | $global_var | AssignMulExpr | +| operations.rb:116:1:116:16 | ... *= ... | *= | operations.rb:116:16:116:16 | 6 | AssignMulExpr | +| operations.rb:116:1:116:16 | ... = ... | = | operations.rb:116:1:116:11 | $global_var | AssignExpr | +| operations.rb:116:1:116:16 | ... = ... | = | operations.rb:116:13:116:14 | ... * ... | AssignExpr | +| operations.rb:116:13:116:14 | ... * ... | * | operations.rb:116:1:116:11 | $global_var | MulExpr | +| operations.rb:116:13:116:14 | ... * ... | * | operations.rb:116:16:116:16 | 6 | MulExpr | +| operations.rb:118:1:118:13 | ... = ... | = | operations.rb:118:1:118:9 | CONSTANT1 | AssignExpr | +| operations.rb:118:1:118:13 | ... = ... | = | operations.rb:118:13:118:13 | 5 | AssignExpr | +| operations.rb:119:1:119:14 | ... += ... | += | operations.rb:119:1:119:9 | CONSTANT2 | AssignAddExpr | +| operations.rb:119:1:119:14 | ... += ... | += | operations.rb:119:14:119:14 | 6 | AssignAddExpr | +| operations.rb:119:1:119:14 | ... = ... | = | operations.rb:119:1:119:9 | CONSTANT2 | AssignExpr | +| operations.rb:119:1:119:14 | ... = ... | = | operations.rb:119:11:119:12 | ... + ... | AssignExpr | +| operations.rb:119:11:119:12 | ... + ... | + | operations.rb:119:1:119:9 | CONSTANT2 | AddExpr | +| operations.rb:119:11:119:12 | ... + ... | + | operations.rb:119:14:119:14 | 6 | AddExpr | +| operations.rb:120:1:120:15 | ... = ... | = | operations.rb:120:1:120:9 | CONSTANT3 | AssignExpr | +| operations.rb:120:1:120:15 | ... = ... | = | operations.rb:120:11:120:13 | ... \|\| ... | AssignExpr | +| operations.rb:120:1:120:15 | ... \|\|= ... | \|\|= | operations.rb:120:1:120:9 | CONSTANT3 | AssignLogicalOrExpr | +| operations.rb:120:1:120:15 | ... \|\|= ... | \|\|= | operations.rb:120:15:120:15 | 7 | AssignLogicalOrExpr | +| operations.rb:120:11:120:13 | ... \|\| ... | \|\| | operations.rb:120:1:120:9 | CONSTANT3 | LogicalOrExpr | +| operations.rb:120:11:120:13 | ... \|\| ... | \|\| | operations.rb:120:15:120:15 | 7 | LogicalOrExpr | +| operations.rb:121:1:121:3 | ... = ... | = | operations.rb:121:1:121:3 | Foo | AssignExpr | +| operations.rb:121:1:121:3 | ... = ... | = | operations.rb:121:1:121:3 | __synth__0 | AssignExpr | +| operations.rb:121:1:121:25 | ... = ... | = | operations.rb:121:1:121:19 | MemberConstant | AssignExpr | +| operations.rb:121:1:121:25 | ... = ... | = | operations.rb:121:21:121:23 | ... \|\| ... | AssignExpr | +| operations.rb:121:1:121:25 | ... \|\|= ... | \|\|= | operations.rb:121:1:121:19 | MemberConstant | AssignLogicalOrExpr | +| operations.rb:121:1:121:25 | ... \|\|= ... | \|\|= | operations.rb:121:25:121:25 | 8 | AssignLogicalOrExpr | +| operations.rb:121:21:121:23 | ... \|\| ... | \|\| | operations.rb:121:1:121:19 | MemberConstant | LogicalOrExpr | +| operations.rb:121:21:121:23 | ... \|\| ... | \|\| | operations.rb:121:25:121:25 | 8 | LogicalOrExpr | +| operations.rb:122:1:122:10 | ... = ... | = | operations.rb:122:1:122:10 | __synth__0 | AssignExpr | +| operations.rb:122:1:122:10 | ... = ... | = | operations.rb:122:1:122:10 | call to bar | AssignExpr | +| operations.rb:122:1:122:31 | ... = ... | = | operations.rb:122:1:122:25 | OtherConstant | AssignExpr | +| operations.rb:122:1:122:31 | ... = ... | = | operations.rb:122:27:122:29 | ... \|\| ... | AssignExpr | +| operations.rb:122:1:122:31 | ... \|\|= ... | \|\|= | operations.rb:122:1:122:25 | OtherConstant | AssignLogicalOrExpr | +| operations.rb:122:1:122:31 | ... \|\|= ... | \|\|= | operations.rb:122:31:122:31 | 7 | AssignLogicalOrExpr | +| operations.rb:122:27:122:29 | ... \|\| ... | \|\| | operations.rb:122:1:122:25 | OtherConstant | LogicalOrExpr | +| operations.rb:122:27:122:29 | ... \|\| ... | \|\| | operations.rb:122:31:122:31 | 7 | LogicalOrExpr | +| operations.rb:123:1:123:17 | ... = ... | = | operations.rb:123:1:123:11 | CONSTANT4 | AssignExpr | +| operations.rb:123:1:123:17 | ... = ... | = | operations.rb:123:13:123:15 | ... \|\| ... | AssignExpr | +| operations.rb:123:1:123:17 | ... \|\|= ... | \|\|= | operations.rb:123:1:123:11 | CONSTANT4 | AssignLogicalOrExpr | +| operations.rb:123:1:123:17 | ... \|\|= ... | \|\|= | operations.rb:123:17:123:17 | 7 | AssignLogicalOrExpr | +| operations.rb:123:13:123:15 | ... \|\| ... | \|\| | operations.rb:123:1:123:11 | CONSTANT4 | LogicalOrExpr | +| operations.rb:123:13:123:15 | ... \|\| ... | \|\| | operations.rb:123:17:123:17 | 7 | LogicalOrExpr | +| operations.rb:124:1:124:3 | ... = ... | = | operations.rb:124:1:124:3 | FOO | AssignExpr | +| operations.rb:124:1:124:3 | ... = ... | = | operations.rb:124:1:124:3 | call to [] | AssignExpr | +| operations.rb:124:1:124:32 | ... = ... | = | operations.rb:124:1:124:20 | (..., ...) | AssignExpr | +| operations.rb:124:1:124:32 | ... = ... | = | operations.rb:124:24:124:32 | [...] | AssignExpr | +| operations.rb:124:6:124:10 | ... = ... | = | operations.rb:124:6:124:10 | BAR | AssignExpr | +| operations.rb:124:6:124:10 | ... = ... | = | operations.rb:124:6:124:10 | call to [] | AssignExpr | +| operations.rb:124:13:124:15 | ... = ... | = | operations.rb:124:13:124:15 | __synth__2 | AssignExpr | +| operations.rb:124:13:124:15 | ... = ... | = | operations.rb:124:13:124:15 | foo | AssignExpr | +| operations.rb:124:13:124:20 | ... = ... | = | operations.rb:124:13:124:20 | FOO | AssignExpr | +| operations.rb:124:13:124:20 | ... = ... | = | operations.rb:124:13:124:20 | call to [] | AssignExpr | +| operations.rb:124:24:124:32 | * ... | * | operations.rb:124:24:124:32 | [...] | SplatExpr | +| operations.rb:124:24:124:32 | ... = ... | = | operations.rb:124:24:124:32 | * ... | AssignExpr | +| operations.rb:124:24:124:32 | ... = ... | = | operations.rb:124:24:124:32 | __synth__3 | AssignExpr | +| operations.rb:126:1:127:1 | ... / ... | / | operations.rb:126:1:126:3 | foo | DivExpr | +| operations.rb:126:1:127:1 | ... / ... | / | operations.rb:127:1:127:1 | 5 | DivExpr | diff --git a/ruby/ql/test/library-tests/ast/operations/operations.rb b/ruby/ql/test/library-tests/ast/operations/operations.rb index cee2acedc707..93ddc39d6384 100644 --- a/ruby/ql/test/library-tests/ast/operations/operations.rb +++ b/ruby/ql/test/library-tests/ast/operations/operations.rb @@ -84,6 +84,26 @@ def foo; return 1, *[2], a:3, **{b:4, c:5} end bar |= 0x01 baz ^= qux +# Assignments with operation at start of line +foo = a + && b +# NOTE: This is not parsed correctly, `|| b` is dropped +# bar = a +# || b + +# Return with `&&` at start of line +def foo(a, b) + return a + && b +end + +# Return with `||` at start of line +# NOTE: This is not parsed correctly, `|| b` is dropped +# def bar(a, b) +# return a +# || b +# end + class X @x = 1 @x += 2 diff --git a/ruby/ql/test/library-tests/ast/operations/unary.expected b/ruby/ql/test/library-tests/ast/operations/unary.expected index 43c23fff0312..2ea6dcf07681 100644 --- a/ruby/ql/test/library-tests/ast/operations/unary.expected +++ b/ruby/ql/test/library-tests/ast/operations/unary.expected @@ -7,7 +7,7 @@ unaryOperations | operations.rb:28:1:28:12 | defined? ... | defined? | operations.rb:28:10:28:12 | foo | DefinedExpr | | operations.rb:29:20:29:23 | * ... | * | operations.rb:29:21:29:23 | [...] | SplatExpr | | operations.rb:29:31:29:42 | ** ... | ** | operations.rb:29:33:29:42 | {...} | HashSplatExpr | -| operations.rb:104:24:104:32 | * ... | * | operations.rb:104:24:104:32 | [...] | SplatExpr | +| operations.rb:124:24:124:32 | * ... | * | operations.rb:124:24:124:32 | [...] | SplatExpr | unaryLogicalOperations | operations.rb:23:1:23:2 | ! ... | ! | operations.rb:23:2:23:2 | a | NotExpr | | operations.rb:24:1:24:5 | not ... | not | operations.rb:24:5:24:5 | b | NotExpr |