Skip to content

Commit 53698ee

Browse files
committed
Merge branch 'topic/fix_is_predefined_op' into 'master'
Fix the "is_predefined_op" stdlib function Closes #382 See merge request eng/libadalang/langkit-query-language!327
2 parents f960433 + e1a41ad commit 53698ee

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lkql_checker/share/lkql/stdlib.lkql

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,14 @@ fun param_pos(n, pos: int = 0) =
194194

195195
# TODO: move this in LAL
196196
fun is_predefined_op(op, follow_renamings=false) =
197-
|" Return true if ``op`` is a predefined operator
197+
|" Return true if ``op`` is a predefined operator; ``op`` can be an Op or
198+
|" a CallExpr.
198199
{
199-
val ref = op.p_referenced_decl();
200-
val real_ref = if follow_renamings then ultimate_subprogram_alias(ref) else ref;
201-
# TODO: remove null check once all operators are synthesized (UB16-053)
202-
if real_ref then real_ref is SyntheticSubpDecl
200+
val ref = if follow_renamings
201+
then ultimate_subprogram_alias(op.p_referenced_decl())
202+
else op.p_referenced_decl();
203+
op is (Op | CallExpr(p_is_call(): true)) and
204+
if ref then ref.p_is_predefined_operator()
203205
}
204206

205207
fun is_standard_numeric(n) =

user_manual/generated/stdlib.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ Functions
145145

146146
.. function:: is_predefined_op(op, follow_renamings=false)
147147

148-
Return true if ``op`` is a predefined operator
148+
Return true if ``op`` is a predefined operator; ``op`` can be an Op or
149+
a CallExpr.
149150

150151
.. function:: is_predefined_type(n)
151152

0 commit comments

Comments
 (0)