compiler issueshttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues2024-03-21T10:58:11+01:00https://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/103Generating bytecode: unknown instruction 'eqR_a' when using pattern-match wit...2024-03-21T10:58:11+01:00Peter AchtenGenerating bytecode: unknown instruction 'eqR_a' when using pattern-match with Real constant valueThe following program compiles (and should), but generating bytecode gives an error:
```
Compiling Example
Optimising Example
Generating bytecode for Example
Unknown instruction 'eqR_a' at line 97.
Generating bytecode failed
```
Minima...The following program compiles (and should), but generating bytecode gives an error:
```
Compiling Example
Optimising Example
Generating bytecode for Example
Unknown instruction 'eqR_a' at line 97.
Generating bytecode failed
```
Minimal program:
```
module Example
:: T = C Real
g :: T -> Bool
g t = case t of
C 0.0 = True
_ = False
Start = g (C 0.0)
```https://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/102undocumented record behaviour2024-03-07T15:35:50+01:00Mart Lubbersundocumented record behaviourThe following code is valid apparently:
```
module test
:: T = {a :: Int, b :: Bool}
Start =
let /*a = 42*/
b = True
in ({T | a, b}, {T | b, a})
a = 42
```
Is this a bug in the compiler or a missing feature in the language re...The following code is valid apparently:
```
module test
:: T = {a :: Int, b :: Bool}
Start =
let /*a = 42*/
b = True
in ({T | a, b}, {T | b, a})
a = 42
```
Is this a bug in the compiler or a missing feature in the language report (section 5.2).John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/99Types used in class have to be imported in icl2024-03-04T14:46:03+01:00Elroy JumpertzTypes used in class have to be imported in iclWhen defining a class in a dcl that relies on types defined in other modules, it is not sufficient to import the types in the dcl only. They also have to be imported in the icl. I think this is counter-intuitive and might be a bug.
Mini...When defining a class in a dcl that relies on types defined in other modules, it is not sufficient to import the types in the dcl only. They also have to be imported in the icl. I think this is counter-intuitive and might be a bug.
Minimal example:
### `Type.dcl`
```
definition module Type
:: MyType = MyType
```
### `Class.dcl`
```
definition module Class
import Type
class foo a where
bar :: a -> MyType
```
### `Class.icl`
```
implementation module Class
Start = 0
```
Running `clm Class` results in `Error [Class.dcl,6,bar]: MyType undefined`.
Adding `import Type` to `Class.icl` solves the problem. I think this is strange.https://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/98"Overloading could not be solved" due to synonym in context2021-08-11T11:29:09+02:00Camil Staps"Overloading could not be solved" due to synonym in contextThe program below fails to compile with an overloading error:
```clean
module list
import StdEnv
Start = f []
f :: !(l String) -> () | List l String
f [|_:xs] = f xs
```
> Overloading error [list.icl,7,f]: internal overloading of "f...The program below fails to compile with an overloading error:
```clean
module list
import StdEnv
Start = f []
f :: !(l String) -> () | List l String
f [|_:xs] = f xs
```
> Overloading error [list.icl,7,f]: internal overloading of "f" could not be solved for: List a String (context does not occur in function type)
Changing the context to `List l {#Char}` makes the program compile, but I think the above should work as well.John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/97Qualified record field assignments require explicit qualified imports of the ...2024-03-08T14:39:49+01:00Camil StapsQualified record field assignments require explicit qualified imports of the record fieldsWhen you import two modules with overlap in field names you can import them qualified and use `'Module'.field` in record assignments. However, this does not work with `import qualified Module` alone: you need specifically `from Module im...When you import two modules with overlap in field names you can import them qualified and use `'Module'.field` in record assignments. However, this does not work with `import qualified Module` alone: you need specifically `from Module import qualified :: Record {..}`. Is this intentional? I would expect that `import qualified Module` is enough.
For example:
```clean
definition module a
:: T = { x :: Int }
definition module b
:: T = { x :: Int }
module c
import qualified a
import qualified b
from a import qualified :: T{..} // <-- why are these two lines needed?
from b import qualified :: T{..}
Start = {'b'.T | 'b'.x = 5}.'b'.x
```John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/96add source information to ABC files2024-03-26T08:19:12+01:00Steffen Michelsadd source information to ABC filesThis is required for debugging crashes of the ABC interpreter in the browser (see https://gitlab.com/clean-and-itasks/itasks-sdk/-/issues/476). It can be a simple filename + line number tag for each function, so that you can match `e__iT...This is required for debugging crashes of the ABC interpreter in the browser (see https://gitlab.com/clean-and-itasks/itasks-sdk/-/issues/476). It can be a simple filename + line number tag for each function, so that you can match `e__iTasks_PExtensions_PGIS_PLeaflet__n__f75_P10431` to the corresponding line.John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/75Don't rebuild instances at runtime2024-03-04T14:35:05+01:00Camil StapsDon't rebuild instances at runtimeIn iTasks we have something like the following:
```clean
:: ReadResult p r w = E.sds: ReadResult !r !(sds p r w) & RWShared sds // | ...
class Identifiable sds where sdsIdentity :: ...
class Readable sds | Identifiable sds where readSD...In iTasks we have something like the following:
```clean
:: ReadResult p r w = E.sds: ReadResult !r !(sds p r w) & RWShared sds // | ...
class Identifiable sds where sdsIdentity :: ...
class Readable sds | Identifiable sds where readSDS :: ...
class Registrable sds | Readable sds where readRegisterSDS :: ...
class Writeable sds | Identifiable sds where writeSDS :: ...
class Modifiable sds | Readable, Writeable sds where modifySDS :: ...
class RWShared sds | Modifiable, Registrable sds
```
Because of this class structure, code to build a `ReadResult` can look like this:
```abc
jsr_eval 0
buildh e_iTasks.Internal.SDS_dsdsIdentity;17 0
buildh e_iTasks.Internal.SDS_dreadSDS;18 0
buildhr e_iTasks.SDS.Definition_rReadable; 2 0
buildh e_iTasks.Internal.SDS_dreadRegisterSDS;21 0
buildhr e_iTasks.SDS.Definition_rRegistrable; 2 0
buildh e_iTasks.Internal.SDS_dsdsIdentity;17 0
buildh e_iTasks.Internal.SDS_dwriteSDS;19 0
buildhr e_iTasks.SDS.Definition_rWriteable; 2 0
buildh e_iTasks.Internal.SDS_dsdsIdentity;17 0
buildh e_iTasks.Internal.SDS_dreadSDS;18 0
buildhr e_iTasks.SDS.Definition_rReadable; 2 0
buildh e_iTasks.Internal.SDS_dmodifySDS;20 0
buildhr e_iTasks.SDS.Definition_rModifiable; 3 0
buildhr e_iTasks.SDS.Definition_rRWShared; 2 0
buildhr e_iTasks.SDS.Definition_kReadResult 3 0
```
This causes a high number of allocated words in these places (as well as requiring some time to generate the records): if I'm counting correctly, 13 words in total for the whole `RWShared` structure. In fact the generated instance is always the same, because the function here is not overloaded. Can we not identify instances like that, and generate these in the data section, as is done with constructors with arity 0? I am looking at an example program here where well over 10% of the allocated words comes from functions like this (and I checked of course that the words allocated in those functions are mainly used for these instances).John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/68Generic instances of unboxed arrays with higher-kinded element types2024-03-04T14:32:47+01:00Camil StapsGeneric instances of unboxed arrays with higher-kinded element typesA while ago we added support for generic instances like `gEq{|{#Int}|}`. However, I can't find a good way to write an instance with a higher-kinded (but fully applied) element type (e.g. `{#R Int}` with `R x = {x :: x}`).
In this exampl...A while ago we added support for generic instances like `gEq{|{#Int}|}`. However, I can't find a good way to write an instance with a higher-kinded (but fully applied) element type (e.g. `{#R Int}` with `R x = {x :: x}`).
In this example program:
```clean
import StdEnv
import StdGeneric
import StdMaybe
generic gId a :: a -> a
:: R x = {x :: x}
gId{|{#R}|} x = x
Start = gId{|*|} {#{x=1}}
```
using `gId{|{#R}|} x = x` fails with `no instance available of type {#R Int}`, and using `gId{|{#R Int|} x = x` fails with `type constructor expected`, then crashes (`no TypeCons`, in `get_type_cons` in module parse).
Using `:: T :== R Int` and `gId{|T|} x = x` works, but should not be necessary.
CC @johnvghttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/59defining record types with overloaded functions on universally quantified var...2024-03-04T14:30:23+01:00Steffen Michelsdefining record types with overloaded functions on universally quantified variablesIt would be convenient to be able to define a record type such as:
```
:: T = { f :: A.a: a -> a | == a }
```It would be convenient to be able to define a record type such as:
```
:: T = { f :: A.a: a -> a | == a }
```John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/54'update undefined' when array updates are used and a local function 'update' ...2019-10-30T11:33:51+01:00Camil Staps'update undefined' when array updates are used and a local function 'update' is definedThe following program does not compile with the error `update undefined`:
```clean
import StdEnv
Start = update {{#1} & [0]=2}
update x = x
```
I imagine this is also a problem for the other members of the Array (and List?) class.The following program does not compile with the error `update undefined`:
```clean
import StdEnv
Start = update {{#1} & [0]=2}
update x = x
```
I imagine this is also a problem for the other members of the Array (and List?) class.https://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/45Some modules can be compiled when imported, but not as a main project module2019-09-16T19:54:30+02:00Camil StapsSome modules can be compiled when imported, but not as a main project moduleWith the example program below, compiling `clm a` works fine, but `clm -PABC b` does not: `Error [b.dcl,5,b]: c generic undefined`. This can be resolved by importing `c` from the `b` implementation module, but why does this error not app...With the example program below, compiling `clm a` works fine, but `clm -PABC b` does not: `Error [b.dcl,5,b]: c generic undefined`. This can be resolved by importing `c` from the `b` implementation module, but why does this error not appear when compiling `a`, which imports `b`?
[imports.tar.gz](/uploads/c79b8d09ea7bf3fe5510d16c6048a000/imports.tar.gz)John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/19derivations are automatically imported, even if using explicit imports2024-03-04T14:17:24+01:00Mart Lubbersderivations are automatically imported, even if using explicit importse.g. The following works while I would expect it to not work.
```
module main
import Text.GenJSON
from Data.Map import :: Map, newMap
Start = JSONEncode{|*|} True map
where
map :: Map Int Int
map = newMap
```e.g. The following works while I would expect it to not work.
```
module main
import Text.GenJSON
from Data.Map import :: Map, newMap
Start = JSONEncode{|*|} True map
where
map :: Map Int Int
map = newMap
```https://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/15Compiler fails to find instances (master) / crashes (itask)2024-03-04T14:24:38+01:00Camil StapsCompiler fails to find instances (master) / crashes (itask)The attached program (main module is `interpretergen`) fails to compile while I believe it should. The current `master` compiler gives:
> Overloading error [target.icl,491,\;491;70]: "to_hword" no instance available of type a
The `itas...The attached program (main module is `interpretergen`) fails to compile while I believe it should. The current `master` compiler gives:
> Overloading error [target.icl,491,\;491;70]: "to_hword" no instance available of type a
The `itask` compiler:
> (THWord.0M:0 [], t)
bindAndAdjustAttrs<Type>: incompatible types (1)
The offending line is `target.icl:492`, where I already tried to hint the type to the compiler using the `:::` which should be superfluous.
There is one more issue, perhaps related: in `interpretergen.icl`, there are several cases where overloading could not be resolved. I marked these with `NB:`. I believe, for instance, that `grow_a (to_hword n_a)` on line 2174 should be allowed to be `grow_a n_a` because the type of `n_a` is known due to `new_local` on line 2164.https://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/11Confusing overloading error2024-03-04T14:22:09+01:00Camil StapsConfusing overloading errorThe compiler correctly gives an error for the code below:
```clean
import StdEnv
f :: b a -> b | + a
f x _ = x + x
```
The error is:
> Overloading error [test.icl,5,f]: internal overloading of "+" could not be solved for: + a (contex...The compiler correctly gives an error for the code below:
```clean
import StdEnv
f :: b a -> b | + a
f x _ = x + x
```
The error is:
> Overloading error [test.icl,5,f]: internal overloading of "+" could not be solved for: + a (context does not occur in function type)
This is confusing (or even incorrect), because `+ a` does occur in the function type. It is `+ b` which is missing.https://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/6expression in where-block are evaluated multiple times if they have a type si...2024-03-04T14:20:22+01:00Steffen Michelsexpression in where-block are evaluated multiple times if they have a type signatureIn this code `x` is only evaluated once:
```
Start = (x, x)
where
x = trace_n "eval" ()
```
If however the type signature is added, `x` is evaluated twice:
```
Start = (x, x)
where
x :: ()
x = trace_n "eval" ()
```
This i...In this code `x` is only evaluated once:
```
Start = (x, x)
where
x = trace_n "eval" ()
```
If however the type signature is added, `x` is evaluated twice:
```
Start = (x, x)
where
x :: ()
x = trace_n "eval" ()
```
This is a pity, as I prefer adding as many type signatures as possible, so I currently loose performance without a reason.