class Test:
publicstaticfinal 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.
Description
Testcase:
class Test:
publicstaticfinal 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.
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.
Fixed in rev. 3151