|
@@ -243,13 +243,13 @@ return {
|
|
["p1(PBase)",
|
|
["p1(PBase)",
|
|
"invalid type cast: 'Base' is not an extension of 'anonymous RECORD'"],
|
|
"invalid type cast: 'Base' is not an extension of 'anonymous RECORD'"],
|
|
["p1(INTEGER)",
|
|
["p1(INTEGER)",
|
|
- "invalid type cast: POINTER type expected as an argument of POINTER type guard, got 'INTEGER'"],
|
|
|
|
|
|
+ "invalid type cast: POINTER type expected as an argument of POINTER type cast, got 'INTEGER'"],
|
|
["i(Derived)",
|
|
["i(Derived)",
|
|
- "invalid type cast: 'Derived' is not an extension of 'INTEGER'"],
|
|
|
|
|
|
+ "invalid type cast: POINTER to type or RECORD expected, got 'INTEGER'"],
|
|
["vb(Derived)",
|
|
["vb(Derived)",
|
|
- "invalid type cast: a value variable cannot be used in typeguard"],
|
|
|
|
|
|
+ "invalid type cast: a value variable cannot be used"],
|
|
["vb(PDerived)",
|
|
["vb(PDerived)",
|
|
- "invalid type cast: a value variable cannot be used in typeguard"])
|
|
|
|
|
|
+ "invalid type cast: a value variable cannot be used"])
|
|
),
|
|
),
|
|
"NIL": testWithContext(
|
|
"NIL": testWithContext(
|
|
context(grammar.expression,
|
|
context(grammar.expression,
|
|
@@ -283,8 +283,10 @@ return {
|
|
fail(["pBase IS pDerived", "type name expected"],
|
|
fail(["pBase IS pDerived", "type name expected"],
|
|
["pBase IS TRUE", "type name expected"],
|
|
["pBase IS TRUE", "type name expected"],
|
|
["pBase IS vDerived", "type name expected"],
|
|
["pBase IS vDerived", "type name expected"],
|
|
- ["Derived IS Derived", "POINTER to type or RECORD expected before 'IS'"],
|
|
|
|
- ["i IS Derived", "POINTER to type or RECORD expected before 'IS'"],
|
|
|
|
|
|
+ ["Derived IS Derived",
|
|
|
|
+ "invalid type test: POINTER to type or RECORD expected, got 'type Derived'"],
|
|
|
|
+ ["i IS Derived",
|
|
|
|
+ "invalid type test: POINTER to type or RECORD expected, got 'INTEGER'"],
|
|
["p^ IS Derived",
|
|
["p^ IS Derived",
|
|
"invalid type test: 'Derived' is not an extension of 'anonymous RECORD'"],
|
|
"invalid type test: 'Derived' is not an extension of 'anonymous RECORD'"],
|
|
["p IS PDerived",
|
|
["p IS PDerived",
|
|
@@ -295,11 +297,26 @@ return {
|
|
"invalid type test: 'Derived' is not an extension of 'Derived'"],
|
|
"invalid type test: 'Derived' is not an extension of 'Derived'"],
|
|
["pDerived^ IS Base",
|
|
["pDerived^ IS Base",
|
|
"invalid type test: 'Base' is not an extension of 'Derived'"],
|
|
"invalid type test: 'Base' is not an extension of 'Derived'"],
|
|
- ["pDerived IS INTEGER", "POINTER to type expected after 'IS'"],
|
|
|
|
- ["pBase IS Derived", "POINTER to type expected after 'IS'"],
|
|
|
|
- ["pBase^ IS PDerived", "RECORD type expected after 'IS'"]
|
|
|
|
|
|
+ ["pDerived IS INTEGER",
|
|
|
|
+ "invalid type test: POINTER type expected as an argument of POINTER type test, got 'INTEGER'"],
|
|
|
|
+ ["pBase IS Derived",
|
|
|
|
+ "invalid type test: POINTER type expected as an argument of POINTER type test, got 'Derived'"],
|
|
|
|
+ ["pBase^ IS PDerived",
|
|
|
|
+ "invalid type test: RECORD type expected as an argument of RECORD type test, got 'PDerived'"]
|
|
)
|
|
)
|
|
),
|
|
),
|
|
|
|
+"IS for VAR argument": testWithContext(
|
|
|
|
+ context(grammar.procedureDeclaration,
|
|
|
|
+ "TYPE Base = RECORD END; Derived = RECORD (Base) i: INTEGER END;"
|
|
|
|
+ + "T = RECORD END; TD = RECORD(T) b: Base END;"),
|
|
|
|
+ pass("PROCEDURE proc(VAR p: Base): BOOLEAN; RETURN p IS Derived END proc"),
|
|
|
|
+ fail(["PROCEDURE proc(p: Base): BOOLEAN; RETURN p IS Derived END proc",
|
|
|
|
+ "invalid type test: a value variable cannot be used"],
|
|
|
|
+ ["PROCEDURE proc(p: TD): BOOLEAN; RETURN p.b IS Derived END proc",
|
|
|
|
+ "invalid type test: a value variable cannot be used"],
|
|
|
|
+ ["PROCEDURE proc(VAR p: T):BOOLEAN; RETURN p(TD).b IS Derived END proc",
|
|
|
|
+ "invalid type test: a value variable cannot be used"])
|
|
|
|
+ ),
|
|
"BYTE": testWithContext(
|
|
"BYTE": testWithContext(
|
|
context(grammar.statement,
|
|
context(grammar.statement,
|
|
"VAR b1, b2: BYTE; i: INTEGER; set: SET; a: ARRAY 3 OF BYTE; ai: ARRAY 3 OF INTEGER;"
|
|
"VAR b1, b2: BYTE; i: INTEGER; set: SET; a: ARRAY 3 OF BYTE; ai: ARRAY 3 OF INTEGER;"
|
|
@@ -1063,11 +1080,11 @@ return {
|
|
+ "T = RECORD END; TD = RECORD(T) b: Base END;"),
|
|
+ "T = RECORD END; TD = RECORD(T) b: Base END;"),
|
|
pass("PROCEDURE proc(VAR p: Base); BEGIN p(Derived).i := 1; END proc"),
|
|
pass("PROCEDURE proc(VAR p: Base); BEGIN p(Derived).i := 1; END proc"),
|
|
fail(["PROCEDURE proc(p: Base); BEGIN p(Derived).i := 1; END proc",
|
|
fail(["PROCEDURE proc(p: Base); BEGIN p(Derived).i := 1; END proc",
|
|
- "invalid type cast: a value variable cannot be used in typeguard"],
|
|
|
|
|
|
+ "invalid type cast: a value variable cannot be used"],
|
|
["PROCEDURE proc(p: TD); BEGIN p.b(Derived).i := 1; END proc",
|
|
["PROCEDURE proc(p: TD); BEGIN p.b(Derived).i := 1; END proc",
|
|
- "invalid type cast: a value variable cannot be used in typeguard"],
|
|
|
|
|
|
+ "invalid type cast: a value variable cannot be used"],
|
|
["PROCEDURE proc(VAR p: T); BEGIN p(TD).b(Derived).i := 1; END proc",
|
|
["PROCEDURE proc(VAR p: T); BEGIN p(TD).b(Derived).i := 1; END proc",
|
|
- "invalid type cast: a value variable cannot be used in typeguard"])
|
|
|
|
|
|
+ "invalid type cast: a value variable cannot be used"])
|
|
),
|
|
),
|
|
"NEW for read only array element fails": testWithContext(
|
|
"NEW for read only array element fails": testWithContext(
|
|
context(grammar.procedureDeclaration,
|
|
context(grammar.procedureDeclaration,
|