TADS Bug Database

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000142TADS 3Compilerpublic2012-02-29 18:282012-04-27 18:21
Reporterbcressey 
Assigned ToMichael Roberts 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformMacintoshOSMacOSOS VersionX
Summary0000142: compile error when using overloaded index operators
DescriptionThe compiler returns this error when I try to use custom index or index & assign operators:

"invalid indexed type in constant expression - list required"
Steps To Reproducemodify WaitAction
    execAction() {
        local test = 1;
        if (testObject.propDefined(&operator []=))
            testObject[1] = 2;
        if (testObject.propDefined(&operator []))
            test = testObject[1];
        "<<test>>";
    }
;

testObject: object
    operator[](b) {
        return b;
    }

    operator[]=(b,c) {
        return self;
    }
;
TagsNo tags attached.
Fixed In Version3.1.1
Attached Files

- Relationships

-  Notes
(0000230)
Michael Roberts (administrator)
2012-04-27 18:21
edited on: 2012-04-27 18:22

The root of the problem is that the compiler was trying to evaluate "testObject[1]" as a constant expression, since both the index value and the value being indexed are compile-time constants (the object name is a constant in the sense that it's a fixed reference to a particular object, even though the object itself isn't a constant). Before operator overloading was added in 3.1, it was a valid assumption that a constant index expression had to be of the form list[integer], since there were no other valid combinations of constants in such an expression; so when the compiler saw something else, it generated the "list required" error. This assumption is no longer true, as this case illustrates. I've changed this so that the compiler recognizes this as a valid combination of constant values in an index expression, and defers evaluation until run-time so that any index operator overload that's in effect will be invoked.


- Issue History
Date Modified Username Field Change
2012-02-29 18:28 bcressey New Issue
2012-04-27 18:21 Michael Roberts Fixed In Version => 3.1.1
2012-04-27 18:21 Michael Roberts Note Added: 0000230
2012-04-27 18:21 Michael Roberts Assigned To => Michael Roberts
2012-04-27 18:21 Michael Roberts Status new => resolved
2012-04-27 18:21 Michael Roberts Resolution open => fixed
2012-04-27 18:22 Michael Roberts Note Edited: 0000230


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker