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::
424
+
Certain Ruby language features are shorthands for common operations that could also be expressed in other, more verbose, forms.
425
+
Such language features are typically referred to as "syntactic sugar", and make it easier for programmers to write and read code. This is
426
+
great for programmers. For source code analyzers, however, this leads to additional work as they need to understand the shorthand notation as well as the long form. To make analysis easier, CodeQL automatically "desugars" Ruby code, effectively rewriting
427
+
rich syntactic constructs into equivalent code that uses simpler syntactic constructs.
428
+
429
+
For example, supposing that ``x`` is an object with an attribute ``foo``, the assignment::
425
430
426
431
x.foo = y
427
432
@@ -432,9 +437,9 @@ is desugared to code similar to::
432
437
433
438
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.
434
439
435
-
In CodeQL, this is implemented by syntheisizingAstNode_ instances corresponding to this desugared version of the code.
440
+
In CodeQL, this is implemented by synthesizingAstNode_ instances corresponding to this desugared version of the code.
436
441
437
-
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.
442
+
Note that the original AssignExpr_ and the desugared SetterMethodCall_ versions are both available to use in CodeQL queries, and you do not usually need to be aware of any desugaring that may take place. However, if a codebase explicitly uses ``x.foo=(y)`` SetterMethodCall_ syntax, you cannot find this syntax by searching for instances of AssignExpr_ .
438
443
439
444
Other synthesized AstNode_ instances exist, see the isSynthesized_ and getDesugared_ predicates for details.
0 commit comments