Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce splitAt to undefined in illegal contexts (copy #2835) #2837

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Nov 2, 2024

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

Still TODO:

  • Write a changelog entry (see changelog/README.md)
  • Check copyright notices are up to date in edited files

This is an automatic copy of pull request #2835 done by [Mergify](https://mergify.com).

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)
@martijnbastiaan martijnbastiaan force-pushed the mergify/copy/1.8/pr-2835 branch from 75580a8 to 7dd87f1 Compare February 11, 2025 08:05
@martijnbastiaan martijnbastiaan enabled auto-merge (squash) February 11, 2025 08:05
@martijnbastiaan martijnbastiaan merged commit 5b936e6 into 1.8 Feb 11, 2025
16 of 17 checks passed
@martijnbastiaan martijnbastiaan deleted the mergify/copy/1.8/pr-2835 branch February 11, 2025 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants