Skip to content

Example clarifying compile-time type validation in patterns #938

@BillWagner

Description

@BillWagner

See #757 (comment)

Original comment on section 11.2.1

I think we may want an example here to clarify this. I believe I get it, but it could be confusing.

For example, consider:

if (x is string s)

It's fine for the compile-time type of x to be object, even though a value whose execution type is object won't match. But the expression type being object is okay because the value might be a string reference. Whereas if the compile-time type of x is (say) Stream then this would be a compile-time error.

Note that in #934 I added the clarifying change from "it is an error" to "it is a compile-time error" referenced in the same conversation.

The additional example is deferred to after C# 7


Associated WorkItem - 178983

Metadata

Metadata

Assignees

Labels

type: clarityWhile not technically incorrect, the Standard is potentially confusing

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions