compiler issueshttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues2018-12-05T15:55:27+01:00https://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/3Issues with multiple instances of the same class in class contexts2018-12-05T15:55:27+01:00Camil StapsIssues with multiple instances of the same class in class contextsThe 2018-12-01 itask compiler has several possibly related issues when a class dictionary contains instances of the same class, as in the example below.
- In `build_context_fields` of checktypes, fields are generated using only the name...The 2018-12-01 itask compiler has several possibly related issues when a class dictionary contains instances of the same class, as in the example below.
- In `build_context_fields` of checktypes, fields are generated using only the names of the classes, causing duplicate symbols. When not using the optimising linker, this triggers a multiple definition error for the example below (``Clean System Files/test.o:(.data.m7+0x8): multiple definition of `e__test__dconvertable_I_Pconvert'``)
- Overloading is not correctly resolved for some members of the context. This can be seen in the function `f` below. If it has the type `a -> Int | convertable a` all is well, with result type `String` the overloading cannot be resolved (`internal overloading of "convert" could not be solved`)
Implementation module:
```clean
implementation module test
import StdEnv
class convert a b :: a -> b
class convertable a | convert a Int & convert a String
instance convert Int Int where convert i = i
instance convert Int String where convert i = toString i
f :: a -> Int | convertable a
f i = convert i
Start = f 10
```
Definition module:
```clean
definition module test
class convert a b :: a -> b
class convertable a | convert a Int & convert a String
instance convert Int Int
instance convert Int String
f :: a -> Int | convertable a
```
@johnvghttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/2strange behaviour of NaN comparison2019-01-14T10:30:37+01:00Steffen Michelsstrange behaviour of NaN comparisonI was trying to find a way to check whether a float is NaN. Comparing NaN number should always yield false, so `not (x == x)` should work, but it doesn't. For this program:
```
import StdEnv
Start = (nan == nan, not (nan == nan))
nan ...I was trying to find a way to check whether a float is NaN. Comparing NaN number should always yield false, so `not (x == x)` should work, but it doesn't. For this program:
```
import StdEnv
Start = (nan == nan, not (nan == nan))
nan = 0.0/0.0
```
I get `(False, False)` as result.
1. Is there another way to check whether a float is NaN?
2. This seems to be a compiler bug.https://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/5required newline for local definitions in ZF expressions2019-01-29T13:58:19+01:00Mart Lubbersrequired newline for local definitions in ZF expressionsIt seems that a local definition in a ZF expression with `let` always requires a newline.
I would expect this to work:
```
Start = [x\\x<-[],let y=1]
```
But a newline is required (even when another generator is placed after the `let`)...It seems that a local definition in a ZF expression with `let` always requires a newline.
I would expect this to work:
```
Start = [x\\x<-[],let y=1]
```
But a newline is required (even when another generator is placed after the `let`)
```
Start = [x\\x<-[],let y=1
]
```
A newline is also required when the let is followed by another generator.
Is this by design?John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/7compiler chrashes with "Run time error, rule 'equalize_atypes_attributes' in ...2019-03-04T16:25:41+01:00Steffen Michelscompiler chrashes with "Run time error, rule 'equalize_atypes_attributes' in module 'overloading' does not match"This is the minimal code for which the problem occurs:
```
:: T a = T
class C a b where
x :: a -> b
instance C (T b) b where
x _ = undef
f = g h
g :: a -> () | C a String
g _ = ()
h :: T a
h = undef
```
If `Int` is used in...This is the minimal code for which the problem occurs:
```
:: T a = T
class C a b where
x :: a -> b
instance C (T b) b where
x _ = undef
f = g h
g :: a -> () | C a String
g _ = ()
h :: T a
h = undef
```
If `Int` is used instead of `String` in the signature of `g`, the problem does not occur.John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/8swapped class arguments with functional dependencies2019-03-07T12:17:17+01:00Steffen Michelsswapped class arguments with functional dependenciesThe compiler gives an error message for the following code, as it derives `f :: T -> () | C T Int`. The instance provided is `C Int T` however.
```
class C a ~b :: a -> b
instance C Int T where
C _ = undef
:: T = T
f :: a -> () |...The compiler gives an error message for the following code, as it derives `f :: T -> () | C T Int`. The instance provided is `C Int T` however.
```
class C a ~b :: a -> b
instance C Int T where
C _ = undef
:: T = T
f :: a -> () | C a Int
f a = g 4 a
g :: a b -> () | C a b
g _ _ = undef
```John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/4Default class members require imports for their implementation2019-03-26T16:54:10+01:00Camil StapsDefault class members require imports for their implementationWhen a class member is a macro, a module importing that member needs to import the definitions from its implementation, which is logical. The same restriction now appears on default class members, however, and I don't think that is neces...When a class member is a macro, a module importing that member needs to import the definitions from its implementation, which is logical. The same restriction now appears on default class members, however, and I don't think that is necessary. Consider the example below. Since `Start` uses the instance of `[]` there is no need for `reverse` to be present in `test`, but this is still required by the import system:
> Error [test.icl,2,import]: function/macro reverse not imported
I think that the imports are only needed if the importing module contains an instance of the class that uses the default class member.
---
test.icl:
```clean
module test
from cls import class children(..), instance children []
Start = children_from_left [1,2,3]
```
cls.dcl:
```clean
definition module cls
from StdList import reverse
class children m
where
children_from_left :: (m a) -> [a]
children_from_left x = reverse (children_from_right x)
children_from_right :: (m a) -> [a]
children_from_right x = reverse (children_from_left x)
instance children []
```
cls.icl:
```clean
implementation module cls
instance children [] where children_from_left xs = xs
```https://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/10aligned non-unifiable types in error messages2019-04-05T15:14:25+02:00Steffen Michelsaligned non-unifiable types in error messagesA simple example is:
```
f :: (a, (b, Bool)) -> Int
f _ = 9
g = f (0.0, (1, 2))
```
This gives:
```
(v2,(v1,Bool))
(Real,(Int,Int))
```
For this simple type it doesn't matter of course, but for more complex types alignment would help:
...A simple example is:
```
f :: (a, (b, Bool)) -> Int
f _ = 9
g = f (0.0, (1, 2))
```
This gives:
```
(v2,(v1,Bool))
(Real,(Int,Int))
```
For this simple type it doesn't matter of course, but for more complex types alignment would help:
```
(v2, (v1, Bool))
(Real ,(Int, Int ))
```
By the way, GHC gives this error:
```
Couldn't match expected type ‘Bool’ with actual type ‘Int’
In the expression: 2 :: Int
In the expression: (1, 2 :: Int)
In the first argument of ‘f’, namely ‘(0.0, (1, 2 :: Int))’
```
Not sure if this is the way to go. I'd prefer coloring to indicate which sub-types match and which do not. Apart from this, alignment would be a good first step.John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/12Compiler crashes when special is used with the wrong kind2019-04-24T13:38:01+02:00Camil StapsCompiler crashes when special is used with the wrong kindFor example, the compiler crashes on compiling the module below in which `m` has kind `*->*` but is given a type of kind `*`:
> TVI_CorrespondenceNumber 0
> type.icl: to_constructor_variable, tvi
```clean
definition module test
imp...For example, the compiler crashes on compiling the module below in which `m` has kind `*->*` but is given a type of kind `*`:
> TVI_CorrespondenceNumber 0
> type.icl: to_constructor_variable, tvi
```clean
definition module test
import StdEnv
f :: (m a) -> Int | length m
special m=Int
```
```clean
implementation module test
import StdEnv
f :: (m a) -> Int | length m
f x = length x
```John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/14Segmentation fault on Windows with {|CONS of {..}|} instead of {|CONS of d|} ...2019-05-15T15:11:38+02:00Camil StapsSegmentation fault on Windows with {|CONS of {..}|} instead of {|CONS of d|} for module-internal genericIn https://gitlab.science.ru.nl/clean-and-itasks/abc-interpreter/issues/78 it turned out that the Windows version of the ABC interpreter crashed under some circumstances. The fix (https://gitlab.science.ru.nl/clean-and-itasks/abc-interpr...In https://gitlab.science.ru.nl/clean-and-itasks/abc-interpreter/issues/78 it turned out that the Windows version of the ABC interpreter crashed under some circumstances. The fix (https://gitlab.science.ru.nl/clean-and-itasks/abc-interpreter/commit/52af2ac14d78a44bd2af77f354ee694d2b933d99) was to change the type of a generic function from `{|CONS of {gcd_name,gcd_arity}|}` to `{|CONS of d=:{gcd_name,gcd_arity}|}` (without using `d` in the body). This should of course not make a difference in behaviour.
I'm attaching the source code which contains the bug; my workaround with `d=:` can be applied in `src/ABC/Parse.icl`. To reproduce the bug, build the project, and run `ABCOptimiser.exe test.abc -o test.opt.abc`.
When generic fusion is turned off the bug does not appear, so perhaps the `d=:` trick only increases the arity so that the bug is avoided by the arity<32 check.
This bug is present on the latest x64 Windows build (May 14), but I have not been able to reproduce it on Linux.
[src.tar.gz](/uploads/48669bf0793edfeb3e963785c1908b49/src.tar.gz)John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/21Polymorph extensible ADTs cannot be extended2019-06-03T15:25:46+02:00Mart LubbersPolymorph extensible ADTs cannot be extendedE.g. if I --- with the following code --- run `clm ext` I get the following error:
```
Error [ext.dcl,5,Poly]: Poly undefined
```
`main.dcl:`
```
definition module main
:: Poly a = Poly a | ..
```
`ext.dcl:`
```
definition module ext
...E.g. if I --- with the following code --- run `clm ext` I get the following error:
```
Error [ext.dcl,5,Poly]: Poly undefined
```
`main.dcl:`
```
definition module main
:: Poly a = Poly a | ..
```
`ext.dcl:`
```
definition module ext
import main
:: Poly a | Ext a
```John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/22Weird error message for impossible anonymous type variable2019-06-03T15:26:02+02:00Camil StapsWeird error message for impossible anonymous type variableThe below code yields an error because of the dot in front of the tuple type, which is impossible since `R` is always unique. The error message is not very helpful:
```
Type error [test2.icl,5,f]:* attribute expected instead of _Tuple2[...The below code yields an error because of the dot in front of the tuple type, which is impossible since `R` is always unique. The error message is not very helpful:
```
Type error [test2.icl,5,f]:* attribute expected instead of _Tuple2[140449386949760]
```
I would expect something like, `* attribute expected instead of uniqueness type variable`, or `uniqueness type variable not allowed here (type must be unique)`.
```
:: *R = {x :: Int}
f :: !R -> .(R, Int)
f r=:{x} = (r, x)
Start = f {x=5}
```John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/23Polymorph currying in class constraint or using forall quantification in clas...2019-06-03T15:26:05+02:00Mart LubbersPolymorph currying in class constraint or using forall quantification in class constraintsThe following code does not work because `a` is not used. But there is an instance that works for any `a`.
```
module test
:: T a = T a
class c a v :: a -> v Int
instance c a T where c a = T 42
fun :: v Int | c a v
fun = c True
Start...The following code does not work because `a` is not used. But there is an instance that works for any `a`.
```
module test
:: T a = T a
class c a v :: a -> v Int
instance c a T where c a = T 42
fun :: v Int | c a v
fun = c True
Start :: T Int
Start = fun
```
However, it works if I change the definition to, but now the function is not as general anymore, I might want to reuse it.
```
fun :: v Int | c Bool v
```
Moreover, say I want to make a function that can do this for a class constraint (hypothetical syntax)
```
instance c a T where c a = T 42
fun :: v Int | c (a | zero a) v
fun = c zero
```
What are the possibilities to possibly allow these constructions in the future.John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/24Unexpected behaviour of type synonyms with type variables2019-06-03T15:26:09+02:00Mart LubbersUnexpected behaviour of type synonyms with type variablesWith the following definitions
```
module test
:: TypeT1 m a = Ty1 (m a)
:: TypeT2 m a = Ty2 (m a)
:: Ident a = Ident a
:: Type1 a :== TypeT1 Ident a
:: Type2 a :== TypeT2 Ident a
```
This is not allowed and throws an error:
```:: S...With the following definitions
```
module test
:: TypeT1 m a = Ty1 (m a)
:: TypeT2 m a = Ty2 (m a)
:: Ident a = Ident a
:: Type1 a :== TypeT1 Ident a
:: Type2 a :== TypeT2 Ident a
```
This is not allowed and throws an error:
```:: ShortHand a :== TypeT1 Type2 a```
```Error [test.icl,14,ShortHand]: Type1 used with wrong arity```
Manually expanding the type synonym works:
```:: ShortHand a :== TypeT1 (TypeT2 Ident) a```John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/25Linux version 2.4 of compiler fails on linking on clean install of ubuntu 18....2019-06-03T15:26:12+02:00Stijn de BoerLinux version 2.4 of compiler fails on linking on clean install of ubuntu 18.04.1/usr/bin/x86_64-linux-gnu-ld: /tmp/linkerWa6Rhn: relocation R_X86_64_32S against `.data' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: final link failed: Nonrepresentable section on output
c.../usr/bin/x86_64-linux-gnu-ld: /tmp/linkerWa6Rhn: relocation R_X86_64_32S against `.data' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/x86_64-linux-gnu-ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit statushttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/26Compiler cannot solve overloading for alias classes2019-06-03T15:26:15+02:00Steffen MichelsCompiler cannot solve overloading for alias classesIn the following code I would say that the class `Alias` is an alias of class `C`. So it should not make a difference which one is used. The code below does however not type-check:
```
class C a where
g :: a
class Alias a | C a
f :...In the following code I would say that the class `Alias` is an alias of class `C`. So it should not make a difference which one is used. The code below does however not type-check:
```
class C a where
g :: a
class Alias a | C a
f :: a -> () | C a
f x = g x
where
g :: a -> () | Alias a
g _ = ()
```
`g` requires `Alias` for `a`, which only include `C` for `a`. `C` is provided by the context so this should type-check, I think.John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/27Type Synonyms with Type Variables2019-06-03T15:26:18+02:00Steffen MichelsType Synonyms with Type VariablesI'd like to be able to define type synonyms containing variables, for instance:
```
:: S a :=== t a b | C t
```
The function type
```
f :: (S x) -> S x | C2 x
```
Should then be equivalent with:
```
f :: (t a b) -> t2 a c | C t & C2 a &...I'd like to be able to define type synonyms containing variables, for instance:
```
:: S a :=== t a b | C t
```
The function type
```
f :: (S x) -> S x | C2 x
```
Should then be equivalent with:
```
f :: (t a b) -> t2 a c | C t & C2 a & C t2
```John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/28Class constrains in let .. in or #2019-06-03T15:26:21+02:00Haye BöhmClass constrains in let .. in or #Code generation fails when there is a constructor containing a dictionary when the constructor is unwrapped in a #, a let .. in, or a where construct. Workaround is to use a case ... of instead.
The following code show the problem conci...Code generation fails when there is a constructor containing a dictionary when the constructor is unwrapped in a #, a let .. in, or a where construct. Workaround is to use a case ... of instead.
The following code show the problem concisely:
```
:: Constr a b = Constr a b & C1 a & C2 b
test :: Constr a b -> a
test c
// Yields wonky behaviour
# Constr a b = c
= a
```
Originally communicated by email with John:
`
Hallo Haye,
On 9/21/2018 2:08 PM, Böhm, H.M. (Haye) wrote:
> Beste John,
>
>
> Er lijkt een bug in de copying garbage collector te zitten, die niet voorkomt in de marking garbage collector. Dit komt voor op zowel Linux als Windows.
De bug zit niet in de garbage collector. Er wordt incorrecte code
gegenereerd voor constructoren die een dictionary bevatten (met een
class constraint dus), en die voorkomen in een (irrefutable) pattern
van een #, let, where of with. In gewone patterns van functies en cases
gaat het wel goed.
In dit geval gaat het om ReadResult in module
iTasks.WF.Combinators.Core, functie eval in functie attach.
Daar staat:
# (Ok (ReadResult
progress=:{InstanceProgress|instanceKey,value,attachedTo} _)) = mbProgress
Als je ReadResult matcht in een functie of case pattern gaat het wel
goed, bijvoorbeeld:
get_InstanceProgress (Ok (ReadResult progress _)) = progress
# progress=:{InstanceProgress|instanceKey,value,attachedTo} =
get_InstanceProgress mbProgress
Ik laat je nog weten wanneer deze bug in de compiler gerepareerd is.
Met vriendelijke groet,
John
>
> Stappen om te reproduceren:
>
> 1. Download de kant-en-klare Clean distributie via https://filesender.surf.nl/?s=download&token=b7af90c8-c606-010c-b883-05abc29659a4.<https://filesender.surf.nl/?s=download&token=b7af90c8-c606-010c-b883-05abc29659a4> Hier zit de development versie van iTasks bij in, en ook een applicatie die de bug veroorzaakt.
> 2. Start de applicatie, te vinden in Development\iTasks-SDK\Examples\HealthApp\HealthAppMain.prj.
> 3. Navigeer in een willekeurige browser naar http://localhost:80.
> 4. Je krijgt een inlogpagina te zien, klik op "continue" rechts onderin.
> 5. Klik in het midden van de pagina op het knopje "New".[cid:c55d0e07-1fd9-4cae-b075-e594c332e9b5]
> 6. Selecteer de bovenste optie in het lijstje wat links verschijnt.
> 7. Klik op "Start task" rechts onderin
> 8. Constateer dat er een segmentation fault optreedt als de copying GC aanstaat en dat er geen fout optreedt als de marking GC aanstaat. Als er geen fout optreedt, verwacht ik het volgende scherm:
>
> [cid:449eef3a-252d-4227-b754-d0e50fcf5536]
>
> Met vriendelijke groet,
>
> Haye
>
>
`https://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/29Compiler crashes with "Run time error, rule 'matchListsOfATypes' in module 'o...2019-06-03T15:26:24+02:00Steffen MichelsCompiler crashes with "Run time error, rule 'matchListsOfATypes' in module 'overloading' does not match"This happens with the following program:
```
import StdEnv, Data.Maybe, Control.Monad
f :: Maybe (Maybe a)
f = return Nothing >>= return
Start = ()
```
This equivalent definition does compile:
```
import StdEnv, Data.Maybe, Control....This happens with the following program:
```
import StdEnv, Data.Maybe, Control.Monad
f :: Maybe (Maybe a)
f = return Nothing >>= return
Start = ()
```
This equivalent definition does compile:
```
import StdEnv, Data.Maybe, Control.Monad
f :: Maybe (Maybe a)
f = return Nothing >>= \x -> return x
Start = ()
```John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/30Changes to class members break some explicit imports2019-06-03T15:26:30+02:00Camil StapsChanges to class members break some explicit importsWith the latest changes to the way the compiler handles macro members, there are issues with explicit imports of classes containing macro members.
On today's itask compiler with today's clean-platform, it seems that any program importin...With the latest changes to the way the compiler handles macro members, there are issues with explicit imports of classes containing macro members.
On today's itask compiler with today's clean-platform, it seems that any program importing Data.Foldable fails to build when building with cpm:
```clean
module fold
import Data.Foldable
Start = 1
```
The errors:
> Error [Data.Foldable.dcl,6,import]: macro foldr not imported
> Error [Data.Foldable.dcl,5,import]: function/macro const not imported
Changing lines 5 and 6 of Foldable.dcl to
```clean
from Data.Functor import class Functor (..), const
from Data.Monoid import class Monoid (..), class Semigroup (..), foldr
```
yields a run-time error in the compiler:
> Run time error, rule '<case>[line:696];15;434' in module 'explicitimports' does not match
(Perhaps this is because Data.Foldable also wants to define foldr?)
Using simple imports of the entire Data.Functor/Monoid modules in Data.Foldable works.
Curiously, the *first* problem (that macros are not imported) does *not* occur when compiling with clm, but the *second* problem (run-time error in the compiler) *does* occur when compiling with clm, although @mlubbers's clm is apparently not immune to the first problem.John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/31Detection of iTask instance not working well2019-06-03T15:26:43+02:00Jurriën Stutterheimj.stutterheim@cs.ru.nlDetection of iTask instance not working wellThe compiler cannot correctly determine whether there exists and instance iTask for a given task argument type.The compiler cannot correctly determine whether there exists and instance iTask for a given task argument type.Jurriën Stutterheimj.stutterheim@cs.ru.nlJurriën Stutterheimj.stutterheim@cs.ru.nl