Closed
Bug 705140
Opened 13 years ago
Closed 13 years ago
[ASC BUG] ASC computes wrong type for result of the "as" operator, errors out in strict mode
Categories
(Tamarin Graveyard :: Tools, defect, P2)
Tamarin Graveyard
Tools
Tracking
(Not tracked)
RESOLVED
FIXED
Q2 12 - Cyril
People
(Reporter: virgilp, Unassigned)
References
Details
Attachments
(1 file)
|
1.05 KB,
patch
|
Details | Diff | Splinter Review |
The new ASC gives compilation errors on code like the following:
var stroke:GraphicsStroke = istroke as GraphicsStroke;
since the "as" operator may return "null", I'm guessing it interprets the type of the expression as "Object" and punts on assignment to GraphicsStroke; (example from avmglue/Graphics.as).
A possibly special (but similar) case is when a Number is converted to "uint" via "as" - e.g.
var a:Number = value;
var b:uint = a as uint;
example: avmglue/System.as, "return totalMemoryNumber as uint" (though in this particular case the usage of 'as' may actually be a bug, IMO).
| Reporter | ||
Updated•13 years ago
|
Blocks: float/float4
Updated•13 years ago
|
OS: Mac OS X → All
Priority: -- → P2
Hardware: x86 → All
Target Milestone: --- → Q2 12 - Cyril
Updated•13 years ago
|
Summary: [ASC BUG] ASC misses type inference on the "as" operator → [ASC BUG] ASC computes wrong type for result of the "as" operator, errors out in strict mode
Comment 1•13 years ago
|
||
Complete test case (file asc.as) that requires only builtin.abc:
------ 8>< ------------------------
function f(y)
{
var x:Date = y as Date;
return x;
}
------ 8>< ------------------------
Error:
[Compiler] Error #1118: Implicit coercion of a value with static type Object
to a possibly unrelated type Date.
asc.as, Ln 3, Col 15:
var x:Date = y as Date;
..............^
Comment 2•13 years ago
|
||
This fixes the problem and probably does not throw away any useful type information. However, it is possible that the correct fix is really elsewhere, for example, in the type matching for assignment or initialization.
We need more test cases to determine if argument passing and assignment are afflicted in the same way initialization is.
Comment 3•13 years ago
|
||
Further testing shows that argument passing and assignment are also affected. Concluding that the proposed fix is good enough.
Updated•13 years ago
|
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•