mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Rust: distinguish [a, b] from [a; b]
This splits the `ArrayExpr` class into `ArrayListExpr` and `ArrayRepeatExpr`. This uses the `synth.from_class` machinery to integrate seamlessly into the generated code, by hiding the extracted `ArrayExpr` behind an internal class and replacing it with a hierarchy of those two classes under a new `ArrayExpr` class.
This commit is contained in:
@@ -550,15 +550,44 @@ class _:
|
||||
"""
|
||||
|
||||
|
||||
@annotate(ArrayExpr, cfg = True)
|
||||
@annotate(ArrayExprInternal)
|
||||
@ql.internal
|
||||
@qltest.skip
|
||||
class _:
|
||||
pass
|
||||
|
||||
class ArrayExpr(Expr):
|
||||
"""
|
||||
An array expression. For example:
|
||||
The base class for array expressions. For example:
|
||||
```rust
|
||||
[1, 2, 3];
|
||||
[1; 10];
|
||||
```
|
||||
"""
|
||||
exprs: list[Expr] | child
|
||||
|
||||
@synth.from_class(ArrayExprInternal)
|
||||
class ArrayListExpr(ArrayExpr):
|
||||
"""
|
||||
An array expression with a list of elements. For example:
|
||||
```rust
|
||||
[1, 2, 3];
|
||||
```
|
||||
"""
|
||||
__cfg__ = True
|
||||
|
||||
@synth.from_class(ArrayExprInternal)
|
||||
class ArrayRepeatExpr(ArrayExpr):
|
||||
"""
|
||||
An array expression with a repeat oeprand and a repeat length. For example:
|
||||
```rust
|
||||
[1; 10];
|
||||
```
|
||||
"""
|
||||
__cfg__ = True
|
||||
|
||||
repeat_operand: Expr | child
|
||||
repeat_length: Expr | child
|
||||
|
||||
|
||||
@annotate(LiteralExpr, cfg = True)
|
||||
|
||||
Reference in New Issue
Block a user