Skip to content

Clearer type errors by respecting type declarations #18569

@Ochnee

Description

@Ochnee

Is your feature request related to a problem? Please describe.

I think this is best explained by showing you why I ended up making this suggestion. I was fixing some code after a bunch of changes in a board game project. I had this error to fix(picture included to show where the error showed up)

Image

I deduced for myself, maybe I'm wrong, that because I'm making the boolean check of "piece <> Nothing" where Nothing is a Piece<'T> instead of a GamePiece<'T>. So the error is sorta assumed in reverse even though I have specified the type on the parameter line.

Here is the code if somebody would like to copy it:

 let checkLine (line : GamePiece<TickTackToePiece> option list) = line.Length > 0 && List.forall (fun piece -> piece <> Nothing && piece = line.Head) line 

Describe the solution you'd like

Stick to declared types when assuming types, rather than the use of a type in a line of code

Additional context
"related: #1103"

Is this is something that could be considered a beginner issue, I would love to give it a shot at some point 👍

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions