mateusfccp / mateusfccp/pinto

Provide an invalid type for failed type inference

Open
#8 2 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue
Dominant language
Dart
Stars
13
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Consider the following program:

```
let myInt = _12_3

let myIntReturningFunction _ = myInt
```

Trying to compile it results in the following:

```
[0:13] Error at '_12_3': The symbol '_12_3' was not found in the scope.
0: let myInt = _12_3
^^^^^
1:
[2:32] Error at 'myInt': The symbol 'myInt' was not found in the scope.
1:
2: let myIntReturningFunction _ = myInt
^^^^^
```

The first error is perfectly fine, as `_12_3` has not been defined in the context.

However, the second error is misleading. `myInt` was not properly defined because type inference failed, but it exists.

Dart deals with it by having a `InvalidType`. This way, we could infer the type of `myInt` to `InvalidType` and treat each case where expect a valid type as an error instead, giving a more proper message.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by compiling the reproducer in the issue and tracing the type-inference and diagnostic paths that handle the unresolved _12_3 and subsequent myInt reference. Determine how an invalid inferred type should propagate through later checks. Done means the original unresolved-symbol error remains, while the follow-up error no longer claims that myInt is absent and invalid-type uses produce appropriate diagnostics.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.