Skip to content

Commit 18aa345

Browse files
committed
Merge branch 'topic/rules/fix_syntax_errors' into 'master'
Fix syntax errors in LKQL codebase Closes #579 See merge request eng/libadalang/langkit-query-language!573
2 parents a138676 + daf5054 commit 18aa345

File tree

3 files changed

+33
-25
lines changed

3 files changed

+33
-25
lines changed

lkql_checker/share/lkql/kp/kp_t805_037.lkql

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
@check(message="possible occurrence of KP T805-037")
66
fun kp_t805_037(node) =
77
node is TypeDecl(
8-
f_discriminants: part@KnownDiscriminantPart,
9-
f_type_def: r@RecordTypeDef(f_record_def: def@RecordDef)
8+
f_discriminants: part@KnownDiscriminantPart,
9+
f_type_def: RecordTypeDef(f_record_def: def@RecordDef)
1010
) when {
11-
val discs = from part select DefiningName;
12-
[decl for decl in
13-
from def.f_components select c@ComponentDecl
14-
when c.f_component_def.f_type_expr is
15-
s@SubtypeIndication(f_constraint: CompositeConstraint(
16-
p_is_discriminant_constraint(): true)
17-
and [id for id in (from c.f_default_expr select Identifier)
18-
if [d for d in discs if d.p_name_matches(id)]]]
11+
val discs = from part select DefiningName;
12+
[
13+
decl for decl in from def.f_components select c@ComponentDecl
14+
when c.f_component_def.f_type_expr is SubtypeIndication(
15+
f_constraint: CompositeConstraint(
16+
p_is_discriminant_constraint(): true
17+
)
18+
)
19+
and [
20+
id for id in (from c.f_default_expr select Identifier)
21+
if [d for d in discs if d.p_name_matches(id)]
22+
]
23+
]
1924
}
20-

lkql_checker/share/lkql/kp/kp_va18_003.lkql

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,20 @@
44
@check(help="possible occurrence of KP VA18-003",
55
message="possible occurrence of KP VA18-003 if No_Tag is passed")
66
fun kp_va18_003(node) =
7-
node is CallExpr(f_suffix: l@AssocList,
8-
p_referenced_decl(): decl@SubpDecl)
9-
when (match decl.p_canonical_fully_qualified_name()
10-
| "^ada\.tags\.descendant_tag$" => true
11-
| "^ada\.tags\.interface_ancestor_tags$" => true
12-
| "^ada\.tags\.is_descendant_at_same_level$" => true
13-
| * => false)
14-
# check all parameters of type Tag
15-
and [a for a in l.children
16-
if a.f_r_expr is not
17-
AttributeRef(f_attribute:
18-
Identifier(p_name_is("Tag"): true) and
19-
a.f_r_expr.p_expression_type().p_relative_name().p_name_is("Tag")]
7+
node is CallExpr(
8+
f_suffix: l@AssocList,
9+
p_referenced_decl(): decl@SubpDecl
10+
) when (
11+
match decl.p_canonical_fully_qualified_name()
12+
| "^ada\.tags\.descendant_tag$" => true
13+
| "^ada\.tags\.interface_ancestor_tags$" => true
14+
| "^ada\.tags\.is_descendant_at_same_level$" => true
15+
| * => false
16+
) and [
17+
# check all parameters of type Tag
18+
a
19+
for a in l.children
20+
if a.f_r_expr is not AttributeRef(
21+
f_attribute: Identifier(p_name_is("Tag"): true)
22+
) and a.f_r_expr.p_expression_type().p_relative_name().p_name_is("Tag")
23+
]

lkql_checker/share/lkql/stdlib.lkql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ fun number_of_values(type) =
552552
|" Return the number of values covered by a given BaseTypeDecl, -1 if
553553
|" this value cannot be determined.
554554
match type
555-
| SubtypeDecl(f_subtype: *(f_constraint: RangeConstraint(f_range: *(f_range: op@BinOp)) => range_values(op.f_left, op.f_right)
555+
| SubtypeDecl(f_subtype: *(f_constraint: RangeConstraint(f_range: *(f_range: op@BinOp)))) => range_values(op.f_left, op.f_right)
556556
| SubtypeDecl => number_of_values(type.f_subtype.f_name.p_referenced_decl())
557557
| * when type == type.p_universal_int_type() => -1
558558
| TypeDecl(f_type_def: type_def) => match type_def

0 commit comments

Comments
 (0)