You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Certain Ruby language features are implemented using syntactic sugar. For example, supposing that ``x`` is an object with an attribute ``foo``, the assignment::
423
+
424
+
x.foo = y
425
+
426
+
is desugared to code similar to::
427
+
428
+
x.foo=(__synth_0 = y);
429
+
__synth_0;
430
+
431
+
In other words, there is effectively a call to the SetterMethodCall_ ``foo=`` on ``x`` with argument ``__synth_0 = y``, followed by a read of the ``__synth_0`` variable.
432
+
433
+
In CodeQL, this is implemented by syntheisizing AstNode_ instances corresponding to this desugared version of the code.
434
+
435
+
Note that both the original AssignExpr_ and the desugared SetterMethodCall_ versions are both available to CodeQL queries, and it is usually not necessary to be aware of any desugaring that may take place. However, if a codebase explicitly uses ``x.foo=(y)`` SetterMethodCall_ syntax, then this will not be found by a query for AssignExpr_ instances.
436
+
437
+
Other synthesized AstNode_ instances exist, see the isSynthesized_ and getDesugared_ predicates for details.
0 commit comments