Skip to content

Execution error when using 'max' function on foreign types in some cases. #6

@rdwebster

Description

@rdwebster

I encountered the problem when comparing Time values, but it also happens for String (another foreign, non-primitive type).

To reproduce, add the following code to a module, compile and run it:

stringTest :: Int;
stringTest = 
    String.length (Prelude.max "abc" "def");

This gives the following run-time error:
Fatal Executor error.
Caused by: java.lang.NoClassDefFoundError: org/openquark/cal_Cal_Test_Data_DataGems__Tests/String_Test, Detail: org/openquark/cal_Cal_Test_Data_DataGems__Tests/String_Test

With LECC source generation turned on, the following error is reported at compilation time:
Error: Code generation aborted. Error generating code for: Cal.Test.Data.DataGems_Tests.stringTest Detail: Unboxed type mismatch in Cal.Test.Data.DataGems_Tests.stringTest : expression type = java.lang.Comparable, desiredType = java.lang.String. Caused by: org.openquark.cal.internal.machine.CodeGenerationException

The problem might be with the way that "deriving Ord" is implemented for foreign types (such as String or Time).
It seems to be mapping this to the Prelude.maxComparable function, which is the correct code but not the correct type signature (unless the appropriate conversions are being added).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions