Issue Details (XML | Word | Printable)

Key: BOO-1127
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Cedric Vivier
Reporter: Cedric Vivier
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Boo

Invalid IL when a static final 'literal' field is assigned to in static constructor

Created: 20/Jan/09 07:05 PM   Updated: 21/Jan/09 04:57 AM   Resolved: 21/Jan/09 04:57 AM
Return to search
Component/s: None
Affects Version/s: 0.8.2
Fix Version/s: 0.9

Time Tracking:
Not Specified

Testcase included: yes


 Description  « Hide

Testcase:

class Test:
    public static final X = 1

    static def constructor():
        X = 2

print Test.X #prints 1 ... or crash

static final with a literal initializer sets the IL flag 'literal'.
Two solutions:
1) forbidding assignment of static final field, even in static constructor
2) implicitely change IL flag to 'initonly' ... but it can be unwanted behavior

I'd take 1, objections?
edit: changed my mind to 2, it makes thing more consistent with the 'instance final' and non-literal types.



Cedric Vivier made changes - 20/Jan/09 07:43 PM
Field Original Value New Value
Description Testcase:
{code}
class Test:
    public static final X = 1

    static def constructor():
        X = 2

print Test.X #prints 1 ... or crash
{code}

static final with a literal initializer sets the IL flag 'literal'.
Two solutions:
1) forbidding assignment of static final field, even in static constructor
2) implicitely change IL flag to 'initonly' ... but it can be unwanted behavior

I'd take 1, objections?
Testcase:
{code}
class Test:
    public static final X = 1

    static def constructor():
        X = 2

print Test.X #prints 1 ... or crash
{code}

static final with a literal initializer sets the IL flag 'literal'.
Two solutions:
1) forbidding assignment of static final field, even in static constructor
2) implicitely change IL flag to 'initonly' ... but it can be unwanted behavior

I'd take 1, objections?
edit: changed my mind to 2, it makes thing more consistent with the 'instance final' and non-literal types.

Cedric Vivier made changes - 20/Jan/09 07:44 PM
Summary Invalid IL when a static final field is assigned to in static constructor Invalid IL when a static final 'literal' field is assigned to in static constructor
Cedric Vivier added a comment - 21/Jan/09 04:57 AM

Fixed in rev. 3151


Cedric Vivier made changes - 21/Jan/09 04:57 AM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]