Skip to content

Commit

Permalink
RA22-015: Use match rt. cast+then
Browse files Browse the repository at this point in the history
In SimpleTypeRef.check_correctness_pre. Also add some comments.
  • Loading branch information
raph-amiard committed Sep 30, 2021
1 parent f8264d9 commit 3035409
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions contrib/lkt/language/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2098,11 +2098,17 @@ def designated_type():

@langkit_property(return_type=T.SemanticResult.array)
def check_correctness_pre():

d = Var(Entity.type_name.referenced_decl)

return d.result_ref.then(
lambda d: d.cast(T.TypeDecl).then(
lambda _: No(T.SemanticResult.array),
default_val=Entity.error(S("Invalid type reference")).singleton
lambda d: d.match(
# The type ref references a type decl: return no error
lambda _=T.TypeDecl: No(T.SemanticResult.array),

# Not a type decl: return an error that the type reference is
# invalid.
lambda _: [Entity.error(S("Invalid type reference"))]
)
)

Expand Down

0 comments on commit 3035409

Please sign in to comment.