---
title: Type Checking
canonical_url: https://mew-lang.org/language/type-checking/
sidecar_url: https://mew-lang.org/language/type-checking.md
content_hash: sha256:92a7c997f9fa11f4e3105dae7a4ed0b8d15ee716628f7416d6ff88edf3bc838a
tokens: 521
uid: language.type-checking
reading_time_minutes: 2
---

Language
# Type Checking

 
`is` asks what a value is, and produces a `bool`.

 
```mew
use std;
  
let number: any = 32;
println($"{number is i32}");
println($"{number is string}");
```

 
```
true
false
```

 
It reads a [type](https://mew-lang.org/language/types.md) you declare, a [union](https://mew-lang.org/language/unions.md), and an [interface](https://mew-lang.org/language/interfaces.md) the value's type implements.

 
```mew
use std;
  
pub interface Describable {
    fn describe() -> string;
}
  
pub type Point {
    pub field x: i32;
    pub field y: i32;
}
  
pub type Circle {
    pub field radius: i32;
}
  
impl Describable for Point {
    pub fn describe() -> string {
        return "a point";
    }
}
  
let boxed: any = new Point { x: 32, y: 40 };
  
println($"{boxed is Point}");
println($"{boxed is Describable}");
println($"{boxed is Circle}");
```

 
```
true
true
false
```

 
Asking about something the compiler already knows is a warning, since the answer cannot be anything else.

 
```mew
let text = "hello";
let known = text is string;
```

 
```
Warning [MEW2041]: The given expression is always of the provided ('string') type
```

 
`is` is how a [cast](https://mew-lang.org/language/type-casting.md) is made safe, because a cast that is wrong ends the program.

 
```mew
use std;
  
pub interface Describable {
    fn describe() -> string;
}
  
pub type Point {
    pub field x: i32;
    pub field y: i32;
}
  
pub type Circle {
    pub field radius: i32;
}
  
impl Describable for Point {
    pub fn describe() -> string {
        return "a point";
    }
}
  
let boxed: any = new Point { x: 32, y: 40 };
  
if boxed is Circle {
    println($"{(boxed as Circle).radius}");
}
```

 
> [!NOTE]
> A union case is not a type, so `is` cannot ask which case a value is. [match](https://mew-lang.org/language/unions.md#reading-a-value) is what asks that.

 
[Previous
                
                Type Casting](https://mew-lang.org/language/type-casting.md)[Next
                    
                Arrays](https://mew-lang.org/language/arrays.md)