-
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.
feat: handle indexed access on columns and rows in type checker
- Loading branch information
1 parent
d6ee42e
commit 3752201
Showing
7 changed files
with
150 additions
and
16 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
41 changes: 41 additions & 0 deletions
41
...fe-ds-lang/tests/resources/validation/types/checking/indexed access on column/main.sdsdev
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,41 @@ | ||
package tests.validation.types.checking.indexedAccessOnColumn | ||
|
||
@Pure fun column() -> column: Column<Int> | ||
@Pure fun index() -> index: Int | ||
|
||
pipeline myPipeline { | ||
// $TEST$ no error r"Expected type .* but got .*\." | ||
column()[»0«]; | ||
|
||
// $TEST$ error "Expected type 'Int' but got 'literal<"">'." | ||
column()[»""«]; | ||
|
||
// $TEST$ no error r"Expected type .* but got .*\." | ||
column()[»index()«]; | ||
|
||
// $TEST$ no error r"Expected type .* but got .*\." | ||
unresolved[»""«]; | ||
} | ||
|
||
class MyColumn sub Column<Int> | ||
|
||
segment mySegment( | ||
myColumn: MyColumn, | ||
) { | ||
// $TEST$ no error r"Expected type .* but got .*\." | ||
myColumn[»0«]; | ||
|
||
// $TEST$ error "Expected type 'Int' but got 'literal<"">'." | ||
myColumn[»""«]; | ||
|
||
// $TEST$ no error r"Expected type .* but got .*\." | ||
myColumn[»index()«]; | ||
} | ||
|
||
// Strict checking of type parameter types | ||
class MyClass<T sub Any>( | ||
p1: T, | ||
|
||
// $TEST$ error "Expected type 'Int' but got 'T'." | ||
a: Any? = column()[»p1«], | ||
) |
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
41 changes: 41 additions & 0 deletions
41
.../safe-ds-lang/tests/resources/validation/types/checking/indexed access on row/main.sdsdev
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,41 @@ | ||
package tests.validation.types.checking.indexedAccessOnRow | ||
|
||
@Pure fun row() -> row: Row | ||
@Pure fun columnName() -> name: String | ||
|
||
pipeline myPipeline { | ||
// $TEST$ no error r"Expected type .* but got .*\." | ||
row()[»""«]; | ||
|
||
// $TEST$ error "Expected type 'String' but got 'literal<1>'." | ||
row()[»1«]; | ||
|
||
// $TEST$ no error r"Expected type .* but got .*\." | ||
row()[»columnName()«]; | ||
|
||
// $TEST$ no error r"Expected type .* but got .*\." | ||
unresolved[»""«]; | ||
} | ||
|
||
class MyRow sub Row | ||
|
||
segment mySegment( | ||
myRow: MyRow, | ||
) { | ||
// $TEST$ no error r"Expected type .* but got .*\." | ||
myRow[»""«]; | ||
|
||
// $TEST$ error "Expected type 'String' but got 'literal<1>'." | ||
myRow[»1«]; | ||
|
||
// $TEST$ no error r"Expected type .* but got .*\." | ||
myRow[»columnName()«]; | ||
} | ||
|
||
// Strict checking of type parameter types | ||
class MyClass<T sub Any>( | ||
p1: T, | ||
|
||
// $TEST$ error "Expected type 'String' but got 'T'." | ||
a: Any? = row()[»p1«], | ||
) |
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