Commit 60c4484
committed
Merge branch 'develop-language-test-typeError'. Close #469.
**Description**
`copilot-language`'s tests fail to compile with GHC 9.4. Prior versions
sometimes made arbitrary decisions during type inference, whereas the
new type checker will simply reject such programs.
For example, compiling `copilot-language`'s tests with GHC 9.4.7 results
in the following error message:
```
Build profile: -w ghc-9.4.7 -O1
In order, the following will be built (use -v for more details):
- copilot-language-3.17 (test:unit-tests) (first run)
Preprocessing test suite 'unit-tests' for copilot-language-3.17..
Building test suite 'unit-tests' for copilot-language-3.17..
[2 of 3] Compiling Test.Copilot.Language.Reify ( tests/Test/Copilot/Language/Reify.hs, /root/copilot/dist-newstyle/build/x86_64-linux/ghc-9.4.7/copilot-language-3.17/t/unit-tests/build/unit-tests/unit-tests-tmp/Test/Copilot/Language/Reify.o )
tests/Test/Copilot/Language/Reify.hs:737:16: error:
* Could not deduce (Copilot.Core.Type.Struct t)
arising from a superclass required to satisfy `Typed t',
arising from a use of `observer'
from the context: (Read t, Eq t, Typed t, Arbitrary t)
bound by a pattern with constructor:
SemanticsP :: forall t.
(Typeable t, Read t, Eq t, Show t, Typed t, Arbitrary t) =>
((Typeable t, Read t, Eq t, Show t, Typed t, Arbitrary t) =>
(Stream t, [t]))
-> SemanticsP,
in an equation for `checkSemanticsP'
at tests/Test/Copilot/Language/Reify.hs:734:33-59
Possible fix:
add (Copilot.Core.Type.Struct t) to the context of
the data constructor `SemanticsP'
* In the expression: observer testObserverName expr
In an equation for `spec': spec = observer testObserverName expr
In the expression:
do let spec = observer testObserverName expr
llSpec <- reify spec
let trace = eval Haskell steps llSpec
let expectation = take steps exprList
....
|
737 | spec = observer testObserverName expr
```
**Type**
- Bug: test fails to compile.
**Additional context**
None.
**Requester**
- Scott Talbert (Debian Developer & Debian Haskell Group)
**Method to check presence of bug**
The following Dockerfile checks that copilot-language compiles with GHC
9.4, in which case it prints the message Success:
```Dockerfile
FROM ubuntu:focal
RUN apt-get update
RUN apt-get install --yes libz-dev
RUN apt-get install --yes git
RUN apt-get install --yes wget
RUN mkdir -p $HOME/.ghcup/bin
RUN wget https://downloads.haskell.org/~ghcup/0.1.19.2/x86_64-linux-ghcup-0.1.19.2 -O $HOME/.ghcup/bin/ghcup
RUN chmod a+x $HOME/.ghcup/bin/ghcup
ENV PATH=$PATH:/root/.ghcup/bin/
ENV PATH=$PATH:/root/.cabal/bin/
RUN apt-get install --yes curl
RUN apt-get install --yes gcc make libgmp3-dev g++
SHELL ["/bin/bash", "-c"]
RUN ghcup install ghc 9.4.7
RUN ghcup install cabal 3.8
RUN ghcup set ghc 9.4.7
RUN cabal update
CMD git clone $REPO && \
cd $NAME && \
git checkout $COMMIT && \
cd copilot-language && \
cabal test . && \
echo Success
```
Command (substitute variables based on new path after merge):
```
$ docker run -e "REPO=https://github.com/Copilot-Language/copilot" -e "NAME=copilot" -e "COMMIT=<HASH>" -it copilot-verify-469
```
**Expected result**
Running the above docker image should print the message success,
indicating that the tests can be compiled without errors (the image
also checks that they run successfully, although for this case we
only really care about the fact that it compiles).
**Proposed solution**
Add type annotation to `spec` in `checkSemanticsP`, to help GHC's type
inference engine.
Comment the change to make sure that future changes do not remove the
signature.
**Further notes**
None.2 files changed
+9
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
1 | 4 | | |
2 | 5 | | |
3 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
732 | 732 | | |
733 | 733 | | |
734 | 734 | | |
735 | | - | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
736 | 740 | | |
737 | 741 | | |
738 | 742 | | |
| |||
0 commit comments