Open sunjay opened 5 years ago
Idea: Whenever we try to resolve a method we don't know the type for, we can add a new "method constraint" to a list. Each method constraint contains the method that was called, the type variable for the Self type, and the type variables for the types of each expression. After the first pass of type inference, before we check for ambiguous variables, we can go through each method constraint and try the following steps:
The Rust compiler has special cases that make it so you don't have to explicitly annotate the type of items on either side of most operators. We should consider similar special casing so we don't need
5int + 6
all the time.For more info, read this whole file:
https://github.com/rust-lang/rust/blob/f54911c6f2971b98ede2d21ab8cabd7daa1110ba/src/librustc_typeck/check/op.rs#L109-L145
https://github.com/sunjay/dino/blob/bd8803d816130dbb1a6b4a53aa058966738bb466/src/ast/parser.rs#L290-L301