compiler issueshttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues2024-03-26T08:19:12+01:00https://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/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/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/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/100Unexpected parse error message when using _createArray2024-03-04T14:43:14+01:00Peter AchtenUnexpected parse error message when using _createArrayHi,
compiling the function definition:
```
import _SystemArray
g = _createArray 42
```
gives the unexpected compiler error message:
```
Parse error [Experiments.icl,42;3,RHS expression]: <expression> expected instead of _createArray
``...Hi,
compiling the function definition:
```
import _SystemArray
g = _createArray 42
```
gives the unexpected compiler error message:
```
Parse error [Experiments.icl,42;3,RHS expression]: <expression> expected instead of _createArray
```
Using:
```
g = createArray 42 ' '
```
gives no problems.
If you're not allowed to use `_createArray`, then a different error message is clearer.
Cheers,
Peterhttps://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/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/13Add the => qualified construct to the master compiler2024-03-04T14:23:13+01:00Camil StapsAdd the => qualified construct to the master compilerIt seems useful to me to add the `=> qualified` construct for imports to the master compiler. It seems to be stable and there are cases where there is no easy workaround (e.g. System.Socket in https://gitlab.science.ru.nl/clean-and-itask...It seems useful to me to add the `=> qualified` construct for imports to the master compiler. It seems to be stable and there are cases where there is no easy workaround (e.g. System.Socket in https://gitlab.science.ru.nl/clean-and-itasks/clean-platform/merge_requests/248). Is there a reason why it is only supported by the iTasks compiler?John van GroningenJohn van Groningenhttps://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.https://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/20Improper detection of iTask constraints2024-03-04T14:07:43+01:00Jurriën Stutterheimj.stutterheim@cs.ru.nlImproper detection of iTask constraintsThe Tonic compiler wrongly considers UserActions to have an iTask constraint, while TaskCont does not have an iTask instance.
```
:: UserActions r o a :== [TaskCont (Room r o a) (Task (Actor o a))]
moveAround :: (Actor o a) (UserAction...The Tonic compiler wrongly considers UserActions to have an iTask constraint, while TaskCont does not have an iTask instance.
```
:: UserActions r o a :== [TaskCont (Room r o a) (Task (Actor o a))]
moveAround :: (Actor o a) (UserActions r o a) (Shared (MAP r o a)) -> Task (Actor o a) | iTask r & iTask o & iTask a & Eq o
moveAround actor actions smap
```Jurriën Stutterheimj.stutterheim@cs.ru.nlJurriën Stutterheimj.stutterheim@cs.ru.nlhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/101newtypes with higher-kinded type variables give a strange error2024-02-19T18:41:01+01:00Mart Lubbersnewtypes with higher-kinded type variables give a strange errornewtypes with higher-kinded type variables give a strange error.
e.g.:
T.dcl:
```
definition module T
:: T0 m a =: T0 (m a)
```
T.icl:
```
implementation module T
```
When compiling gives the following error:
```
Error [T.dcl,3,T0]: ...newtypes with higher-kinded type variables give a strange error.
e.g.:
T.dcl:
```
definition module T
:: T0 m a =: T0 (m a)
```
T.icl:
```
implementation module T
```
When compiling gives the following error:
```
Error [T.dcl,3,T0]: m attribute variable not allowed
```John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/95make it possible to a type variable introduced in the type specification o...2022-02-04T11:32:07+01:00Steffen Michelsmake it possible to a type variable introduced in the type specification of a surrounding function in the specification for local functionsThis is not possible (see "3.7 Typing Functions" of the language report). The example given is:
```
f:: a -> (a,a)
f x = g x
where
// g:: b -> (a^,b)
g y = (x,y)
```
This feature would be highly desirable to:
* improve readabi...This is not possible (see "3.7 Typing Functions" of the language report). The example given is:
```
f:: a -> (a,a)
f x = g x
where
// g:: b -> (a^,b)
g y = (x,y)
```
This feature would be highly desirable to:
* improve readability of the code
* improve performance (e.g. the tuple returned by `g` in the example above cannot be made strict without type annotation)John van GroningenJohn van Groningenhttps://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/94identifiers of ?None constructors still contain "Nothing"2021-04-23T16:54:39+02:00Steffen Michelsidentifiers of ?None constructors still contain "Nothing"The identifiers are still e.g. "_!Nothing". Wouldn't "_?None" be more consistent with the actual syntax?The identifiers are still e.g. "_!Nothing". Wouldn't "_?None" be more consistent with the actual syntax?John van GroningenJohn van Groningenhttps://gitlab.science.ru.nl/clean-compiler-and-rts/compiler/-/issues/93Compiler ignores `-o` option2021-04-10T11:15:21+02:00Erin van der VeenCompiler ignores `-o` optionThe `-o` option for the compiler is parsed but never used. This makes it impossible to specify where the `.abc` files should go, in turn making it impossible to use the compiler in the usual way on a system where `$CLEAN_HOME` is read-on...The `-o` option for the compiler is parsed but never used. This makes it impossible to specify where the `.abc` files should go, in turn making it impossible to use the compiler in the usual way on a system where `$CLEAN_HOME` is read-only.
This was noted on the `itask` branch of the compiler. Not checked for `master`.John van GroningenJohn van Groningen