Skip to content

Comparing CArray and CString is accepted as valid code but leads to random results #153

@PtrMan

Description

@PtrMan

The compiler accepts comparison between a char CArray and a CString but it is not compiled/executed as a string comparison correctly! (results here are random).

struct Instr {
    var mnem: CArray[Char, 8]; // mnemonic of op
    var valF: Float32;
}

// interpret instruction
function interp(instr: Instr, stack: Ptr[Stack]) {
    if (instr.mnem) == "PUSHCF  " {
        stack.arr[stack.idx++] = instr.valF; // push
        printf("PUSH\n");
    }
    else if instr.mnem == "LININTER" {
        var intr = stack.arr[stack.idx--];
        var b = stack.arr[stack.idx--];
        var a = stack.arr[stack.idx--];
        
        stack.arr[stack.idx++] = a*(1.0-intr) + (b-a)*intr;
        printf("LININTER\n");
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions