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)

defect

Tracking

(Not tracked)

RESOLVED FIXED
Q2 12 - Cyril

People

(Reporter: virgilp, Unassigned)

References

Details

Attachments

(1 file)

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).
Blocks: float/float4
OS: Mac OS X → All
Priority: -- → P2
Hardware: x86 → All
Target Milestone: --- → Q2 12 - Cyril
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
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; ..............^
Attached patch Tentative fixSplinter Review
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.
Further testing shows that argument passing and assignment are also affected. Concluding that the proposed fix is good enough.
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.

Attachment

General

Creator:
Created:
Updated:
Size: