-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(typecheck): make a bit more robust
- Loading branch information
Showing
17 changed files
with
277 additions
and
19 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
19 changes: 19 additions & 0 deletions
19
crates/kyac/snapshots/kyac__pass__typecheck__tests__free_fun_cast_err.snap
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,19 @@ | ||
--- | ||
source: crates/kyac/src/pass/typecheck.rs | ||
expression: errors | ||
--- | ||
Err( | ||
[ | ||
PreciseError { | ||
filename: "test-cases/typecheck/generics/free-fun-cast-err.kya", | ||
heading: "Foo is not a subclass of T", | ||
source: " freeFunction(foo);", | ||
span: Span { | ||
line: 11, | ||
column: 18, | ||
length: 3, | ||
}, | ||
text: "expression of type Foo", | ||
}, | ||
], | ||
) |
19 changes: 19 additions & 0 deletions
19
crates/kyac/snapshots/kyac__pass__typecheck__tests__method_cast_err.snap
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,19 @@ | ||
--- | ||
source: crates/kyac/src/pass/typecheck.rs | ||
expression: errors | ||
--- | ||
Err( | ||
[ | ||
PreciseError { | ||
filename: "test-cases/typecheck/generics/method-cast-err.kya", | ||
heading: "Bar is not a subclass of T", | ||
source: " foo.print(bar);", | ||
span: Span { | ||
line: 14, | ||
column: 15, | ||
length: 3, | ||
}, | ||
text: "expression of type Bar", | ||
}, | ||
], | ||
) |
19 changes: 19 additions & 0 deletions
19
crates/kyac/snapshots/kyac__pass__typecheck__tests__type_param_shadow.snap
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,19 @@ | ||
--- | ||
source: crates/kyac/src/pass/typecheck.rs | ||
expression: errors | ||
--- | ||
Err( | ||
[ | ||
PreciseError { | ||
filename: "test-cases/typecheck/generics/type-param-shadow.kya", | ||
heading: "`T` already defined", | ||
source: " fun print<T: Print>(self, val: T) {}", | ||
span: Span { | ||
line: 6, | ||
column: 15, | ||
length: 1, | ||
}, | ||
text: "", | ||
}, | ||
], | ||
) |
19 changes: 19 additions & 0 deletions
19
crates/kyac/snapshots/kyac__pass__typecheck__tests__undef_generic_type.snap
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,19 @@ | ||
--- | ||
source: crates/kyac/src/pass/typecheck.rs | ||
expression: errors | ||
--- | ||
Err( | ||
[ | ||
PreciseError { | ||
filename: "test-cases/typecheck/generics/undef-generic-type.kya", | ||
heading: "`R` is not defined", | ||
source: " fun print<T: Print>(self, val: R) {}", | ||
span: Span { | ||
line: 6, | ||
column: 36, | ||
length: 1, | ||
}, | ||
text: "", | ||
}, | ||
], | ||
) |
19 changes: 19 additions & 0 deletions
19
crates/kyac/snapshots/kyac__pass__typecheck__tests__undef_type_param_free_fun.snap
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,19 @@ | ||
--- | ||
source: crates/kyac/src/pass/typecheck.rs | ||
expression: errors | ||
--- | ||
Err( | ||
[ | ||
PreciseError { | ||
filename: "test-cases/typecheck/generics/undef-generic-type-free-fun.kya", | ||
heading: "`R` is not defined", | ||
source: "fun freeFunction<T: Print>(val: R) {}", | ||
span: Span { | ||
line: 7, | ||
column: 33, | ||
length: 1, | ||
}, | ||
text: "", | ||
}, | ||
], | ||
) |
19 changes: 19 additions & 0 deletions
19
crates/kyac/snapshots/kyac__pass__typecheck__tests__unsatisfied_bounds.snap
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,19 @@ | ||
--- | ||
source: crates/kyac/src/pass/typecheck.rs | ||
expression: errors | ||
--- | ||
Err( | ||
[ | ||
PreciseError { | ||
filename: "test-cases/typecheck/generics/unsatisfied-bounds.kya", | ||
heading: "Baz does not satisfy bound Print", | ||
source: " let bar: Bar<Baz> = Bar:init(x: Baz:init());", | ||
span: Span { | ||
line: 16, | ||
column: 14, | ||
length: 3, | ||
}, | ||
text: "in instantiation of type here", | ||
}, | ||
], | ||
) |
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
12 changes: 12 additions & 0 deletions
12
crates/kyac/test-cases/typecheck/generics/free-fun-cast-err.kya
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,12 @@ | ||
class Print { | ||
fun print(self) {} | ||
} | ||
|
||
class Foo {} | ||
|
||
fun freeFunction<T: Print>(val: T) {} | ||
|
||
fun main() { | ||
let foo: Foo = Foo:init(); | ||
freeFunction(foo); | ||
} |
15 changes: 15 additions & 0 deletions
15
crates/kyac/test-cases/typecheck/generics/method-cast-err.kya
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,15 @@ | ||
class Print { | ||
fun print(self) {} | ||
} | ||
|
||
class Foo { | ||
fun print<T: Print>(self, val: T) {} | ||
} | ||
|
||
class Bar {} | ||
|
||
fun main() { | ||
let bar: Bar = Bar:init(); | ||
let foo: Foo = Foo:init(); | ||
foo.print(bar); | ||
} |
11 changes: 11 additions & 0 deletions
11
crates/kyac/test-cases/typecheck/generics/type-param-shadow.kya
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,11 @@ | ||
class Print { | ||
fun print(self) {} | ||
} | ||
|
||
class Foo<T> { | ||
fun print<T: Print>(self, val: T) {} | ||
} | ||
|
||
class Bar {} | ||
|
||
fun main() {} |
12 changes: 12 additions & 0 deletions
12
crates/kyac/test-cases/typecheck/generics/undef-generic-type-free-fun.kya
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,12 @@ | ||
class Print { | ||
fun print(self) {} | ||
} | ||
|
||
class Foo {} | ||
|
||
fun freeFunction<T: Print>(val: R) {} | ||
|
||
fun main() { | ||
let foo: Foo = Foo:init(); | ||
freeFunction(foo); | ||
} |
15 changes: 15 additions & 0 deletions
15
crates/kyac/test-cases/typecheck/generics/undef-generic-type.kya
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,15 @@ | ||
class Print { | ||
fun print(self) {} | ||
} | ||
|
||
class Foo { | ||
fun print<T: Print>(self, val: R) {} | ||
} | ||
|
||
class Bar {} | ||
|
||
fun main() { | ||
let bar: Bar = Bar:init(); | ||
let foo: Foo = Foo:init(); | ||
foo.print(bar); | ||
} |
17 changes: 17 additions & 0 deletions
17
crates/kyac/test-cases/typecheck/generics/unsatisfied-bounds.kya
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,17 @@ | ||
class Print { | ||
fun print(self) {} | ||
} | ||
|
||
class Foo<T> { | ||
x: T | ||
} | ||
|
||
class Bar<T: Print> {} | ||
|
||
class Baz {} | ||
|
||
fun main() { | ||
% currently not functional | ||
% let foo: Foo<int> = Foo:init(x: 5); | ||
let bar: Bar<Baz> = Bar:init(x: Baz:init()); | ||
} |
Oops, something went wrong.