Skip to content

Commit

Permalink
RA22-015: Fix to_iterator's signature
Browse files Browse the repository at this point in the history
Will be needed for an upcoming fix on call resolution. For the moment
to_iterator is unparsed as a regular function call in dsl_unparse, but
in the prelude it's a property, so unify towards it being a function.
Some discrepancies (see entity_iterator test) are ignored for the moment
due to a hole in type resolution.
  • Loading branch information
raph-amiard committed Sep 30, 2021
1 parent 152ca4e commit 39925cd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contrib/lkt/language/prelude.lkt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ trait Iterator {

@builtin generic[T]
struct Array implements Sized, Indexable[T], Iterator[T] {
@builtin @property fun to_iterator(): Iterator[T]
@builtin fun to_iterator(): Iterator[T]
}

@builtin generic[T]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ class Name : RootNode implements TokenNode {
fun parent_nodes (): Array[RootNode] = node.parents()
fun parent_nodes (): Array[RootNode] = node.parents(with_self=false)

fun node_iterator (): Iterator[RootNode] = node.parents().to_iterator
fun node_iterator (): Iterator[RootNode] = node.parents().to_iterator()

}
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,11 @@ Id <RefId "to_iterator" test.lkt:26:63-26:74>
references <FunDecl prelude: "to_iterator">

Expr <RefId "to_iterator" test.lkt:26:63-26:74>
has type <InstantiatedGenericType prelude: "Iterator[RootNode]">
has type <FunctionType prelude: "() -> Iterator[RootNode]">

Expr <DotExpr test.lkt:26:48-26:74>
has type <FunctionType prelude: "() -> Iterator[RootNode]">

Expr <CallExpr test.lkt:26:48-26:76>
has type <InstantiatedGenericType prelude: "Iterator[RootNode]">

0 comments on commit 39925cd

Please sign in to comment.