-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ff1227
commit 67532b5
Showing
3 changed files
with
82 additions
and
17 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,44 @@ | ||
// RUN: not zirgen --emit=zhlt %s 2>&1 | FileCheck %s | ||
|
||
// This test covers diagnostics related to implicit layout arguments. When a | ||
// component constructor makes use of the layout of a parameter, for example to | ||
// compute a back on it or to alias the layout, the compiler adds the layout as | ||
// an implicit argument and in turn must resolve the layout at the call sites. | ||
// Sometimes this isn't feasible, so we add a few diagnostics to make it easier | ||
// to understand why that is. | ||
|
||
component A(a: Val) { | ||
a := Reg(a); | ||
} | ||
|
||
component B(a: A) { | ||
aa := a; | ||
extra := Reg(0); | ||
aa | ||
} | ||
|
||
component TakeAsValueOnly(a: A) {} | ||
|
||
component TakeAsValueAndLayout(a: A) { | ||
[email protected] // Make sure the layout of the parameter is actually used | ||
} | ||
|
||
test { | ||
a := A(1); | ||
b := B(a); | ||
|
||
// No error | ||
// CHECK-NOT: :[[# @LINE + 1]]:{{[0-9]+}}: error | ||
TakeAsValueOnly(b); | ||
|
||
|
||
// the super of b is not part of the layout of b | ||
// CHECK: error: type `B` does not own a super layout of type `A` | ||
// CHECK: :[[# @LINE + 1]]:{{[0-9]+}}: note: which is expected by this constructor call: | ||
TakeAsValueAndLayout(b); | ||
|
||
// the layout of aa is not part of the layout of b | ||
// CHECK: error: type `B` does not own the layout of member "aa" | ||
// CHECK: :[[# @LINE + 1]]:{{[0-9]+}}: note: which is expected by this constructor call: | ||
TakeAsValueAndLayout(b.aa); | ||
} |