-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1087 from hylo-lang/typecheck-for-stmt
Type check for loops
- Loading branch information
Showing
15 changed files
with
483 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// A type that supplies the elements of a list one at a type. | ||
/// | ||
/// An iterator encapsulates the necessary state and logic to produce the elements of a possibly | ||
/// unbounded list, one after the other. Elements are returned by `next()`, which returns either | ||
/// the next element in the list or `None` if all elements have been returned. | ||
/// | ||
/// Use `Iterator` to implement single-pass iteration algorithms that take ownership of the values | ||
/// on which they iterate. You can "step through" the elements of an iterator using a for-loop: | ||
/// | ||
/// for let x in some_iterator { print(x) } | ||
/// | ||
/// An `Iterator` typically does not model a `Collection`. | ||
public trait Iterator { | ||
|
||
/// The type of the elements produced by `Self`. | ||
type Element | ||
|
||
/// Advances to the next element and returns it, or `None` if no next element exists. | ||
fun next() inout -> Optional<Element> | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/// The declaration of a type's conformance to one or multiple traits. | ||
public protocol ConformanceSource: ExposableDecl { | ||
|
||
/// The names of traits to which the type conforms. | ||
var conformances: [NameExpr.ID] { get } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/// The declaration and site from which an explicit conformance originates. | ||
public struct ConformanceOrigin { | ||
|
||
/// The declaration of the conformance. | ||
public let source: AnyDeclID | ||
|
||
/// The site at which diagnostics related to the conformance are reported. | ||
public let site: SourceRange | ||
|
||
/// Creates an instance with the given properties. | ||
public init<T: ConformanceSource>(_ source: T.ID, at site: SourceRange) { | ||
self.source = AnyDeclID(source) | ||
self.site = site | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Core | ||
|
||
/// How a binding declaration is being used. | ||
enum BindingDeclUse: Hashable { | ||
|
||
/// The declaration is used to introduce new bindings unconditionally. | ||
/// | ||
/// The pattern matches any possible value produced by the declaration's initializer, if present. | ||
case irrefutable | ||
|
||
/// The declaration is used as a condition. | ||
/// | ||
/// The pattern acts as a condition that is satisfied iff it matches the value of the | ||
/// declaration's initializer, which must be present. | ||
case condition | ||
|
||
/// The declaration is used as a filter. | ||
/// | ||
/// The pattern acts as a condition that is satisfied iff it matches an instance of the payload. | ||
case filter(matching: AnyType) | ||
|
||
/// The type that is narrowed by the pattern of the declaration if it is used as a filter. | ||
var filteredType: AnyType? { | ||
if case .filter(let t) = self { | ||
return t | ||
} else { | ||
return nil | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.