Project

General

Profile

Bug #87

SYSTEM.VAL does not compile

Added by Patrick Hunziker 8 months ago. Updated 7 months ago.

Status:
In Progress
Priority:
Normal
Assignee:
-
Category:
Compiler

Description

I believe it should compile.
see attached module.

TYPE 
    Color*=ARRAY [4] OF UNSIGNED8;
    VColor*= ARRAY [4] OF UNSIGNED8;

    OPERATOR ":="*(VAR l:Color; r:UNSIGNED32); 
    BEGIN
        l:=SYSTEM.VAL(Color,r)
    END ":=";

    OPERATOR ":="*(VAR l:UNSIGNED32; CONST r:Color); 
    BEGIN
        l:=SYSTEM.VAL(UNSIGNED32,r)
    END ":=";

Colors_.Mod (4.05 KB) Colors_.Mod Patrick Hunziker, 20 November 2019 09:17

History

#1 Updated by Felix Friedrich 7 months ago

A minimal example that reproduces your problems is the following:

MODULE Test;

IMPORT SYSTEM;

TYPE 
    Color*=ARRAY [4] OF UNSIGNED8;

    OPERATOR ":="*(VAR l: Color; CONST i: ARRAY [4] OF SIGNED32);
    BEGIN
    END ":=";

VAR l,r: Color;
BEGIN
    l := r;
END Test.

The compiler reports a "recursive Conversion". The problem is that during assignment of Color to Color the compiler tries to use the assignment operator provided and after the implicit conversion tries to assign a Color to a Color again (implicitly). This must be repaired in the compiler. Because there are implicit conversions possible (as they were requested) a simple assignment can now become an expensive operation. Because it must be possible to allow for overloading of assignment T to T, an absence of this explicit conversion operator must be handled differently by the compiler. The assignment of T to T should never go via different types.

Will be fixed.

#2 Updated by Felix Friedrich 7 months ago

  • Status changed from New to In Progress

#3 Updated by Felix Friedrich 7 months ago

  • Category set to Compiler

Also available in: Atom PDF