compiler: Type Check All Binary Operators
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
This commit is contained in:
@@ -463,3 +463,32 @@ import TreeSitterP4
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
@Test func test_field_read_equality_invalid_type() async throws {
|
||||
let simple_parser_declaration = """
|
||||
parser main_parser() {
|
||||
state start {
|
||||
transition select (ts.yesno == "testing") {
|
||||
true: accept;
|
||||
false: reject;
|
||||
};
|
||||
}
|
||||
};
|
||||
"""
|
||||
var test_declarations = VarTypeScopes().enter()
|
||||
let fields = P4StructFields([
|
||||
P4StructFieldIdentifier(name: "yesno", withType: P4QualifiedType(P4Boolean())),
|
||||
P4StructFieldIdentifier(name: "count", withType: P4QualifiedType(P4Int())),
|
||||
])
|
||||
let struct_type = P4Struct(withName: Identifier(name: "Testing"), andFields: fields)
|
||||
test_declarations = test_declarations.declare(identifier: Identifier(name: "ts"), withValue: P4QualifiedType(struct_type))
|
||||
|
||||
#expect(
|
||||
#RequireErrorResult(
|
||||
Error(
|
||||
withMessage: "{68, 21}: Could not parse transition select expression selector expression: Types of values used with binary expression are not the same"
|
||||
),
|
||||
Program.Compile(simple_parser_declaration, withGlobalInstances: test_declarations))
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user