-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Previously, the Clash compiler would try to reduce ``` splitAt d1 Nil ``` to something of type ``` (Vec 1 a, Vec (0-1) a) ``` by trying to project the head and the tail out of the `Nil` constructor. This of course does not work resulting in an out-of-bounds indexing error reported in: #2831 The compiler now reduces above expressions to: ``` undefined :: (Vec 1 a, Vec (0-1) a) ``` Which is morally equivalent to the run-time exception Haskell evaluation would have thrown if the circuit description was evaluated like a regular Haskell program. Fixes #2831 (cherry picked from commit 10f26ff) Co-authored-by: Christiaan Baaij <[email protected]>
- Loading branch information
1 parent
9efba5d
commit 5b936e6
Showing
4 changed files
with
33 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
FIXED: Clash errors out when `Clash.Sized.Vector.splitAt` is compile-time evaluated in an illegal context |
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,14 @@ | ||
module T2831 where | ||
|
||
import Clash.Prelude | ||
|
||
f :: forall n. SNat n -> Unsigned 4 | ||
f n@SNat = case compareSNat n (SNat @15) of | ||
SNatLE -> at @n @(16 - n - 1) SNat vec | ||
SNatGT -> 0 | ||
where | ||
vec :: Vec 16 (Unsigned 4) | ||
vec = repeat 1 | ||
|
||
topEntity :: Unsigned 4 | ||
topEntity = f d17 |