Comments (7)
Good timing, I was just working on improving the overload errors yesterday! I just added a heuristic that prefers other errors other the unify errors (which I also changed to 'type mismatch' and added more location info.
This is another good heuristic, so I will add it as well
from sail.
Yes, in the scheme I described that would cause us to stop immediately on the second bullet point.
from sail.
which I also changed to 'type mismatch'
Ah yeah I was going to suggest that too. I assume "unify" is some standard PL theory term, and it's kind of clear from the context what it means but it did confuse me for a second! Type mismatch is much clearer.
from sail.
I think maybe the way to go is to do the following when we encounter an overload:
- Construct an 'overload tree' of subexpressions
- (Partially) infer the type of any obvious leaves, where obvious leaves are things like identifiers, function calls, etc
- Use those partial types to rule out any overloads that cannot apply, pruning the tree down to a smaller set of possibilities.
If we checked overloads like that, we'd essentially get this heuristic for free just from the way the typing rule worked. It would also be a performance optimisation, because we would rule out impossible cases earlier and not waste time exploring them.
from sail.
Maybe I'm being dumb, but when you get to an identifier and try to figure out what it is and you don't find any definitions for that identifier or any type (variable, function, etc), can't you immediately stop?
I wouldn't be surprised if the error is more confusing if that item exists but is the wrong type (e.g. trying to call a variable) but if literally no item exists with the name it seems like you could do an early stop and report that very clearly.
I have never written a compiler though (does a WASM to TCL transpiler count? 😄), let alone a fancy dependently typed one so sorry if I am spewing nonsense!
from sail.
With #526 the following:
default Order dec
$include <prelude.sail>
val main : unit -> unit
function main() = {
let bv: bits(32) = 0xFFFF_FFFF;
let _ = bv | bv | bv | bv | b;
()
}
now prints:
Type error:
test.sail:9.32-33:
9 | let _ = bv | bv | bv | bv | b;
| ^
| Identifier b is unbound. Did you mean bv?
whereas before it printed:
Type error:
test.sail:9.12-33:
9 | let _ = bv | bv | bv | bv | b;
| ^-------------------^ (operator |)
| No overloading for (operator |), tried:
| * or_vec
| test.sail:9.17-33:
| 9 | let _ = bv | bv | bv | bv | b;
| | ^--------------^ checking function argument has type bitvector(32)
| | No overloading for (operator |), tried:
| | * or_vec
| | test.sail:9.22-33:
| | 9 | let _ = bv | bv | bv | bv | b;
| | | ^---------^ checking function argument has type bitvector(32)
| | | No overloading for (operator |), tried:
| | | * or_vec
| | | test.sail:9.27-33:
| | | 9 | let _ = bv | bv | bv | bv | b;
| | | | ^----^ checking function argument has type bitvector(32)
| | | | No overloading for (operator |), tried:
| | | | * or_vec
| | | | test.sail:9.32-33:
| | | | 9 | let _ = bv | bv | bv | bv | b;
| | | | | ^ checking function argument has type bitvector(32)
| | | | | Identifier b is unbound. Did you mean bv?
| | | |
| | | | Also tried or_bool
| | |
| | | Also tried or_bool
| |
| | Also tried or_bool
|
| Also tried or_bool
| This seems less likely, use --explain-all-overloads to see full details
from sail.
Much better, thanks!
from sail.
Related Issues (20)
- Miscompilation involving tuples and options HOT 2
- Major regression in compile time due to improved error messages HOT 6
- Slightly weird wording in error message HOT 1
- Rename `sail2` branch to `master` HOT 3
- Provide binary download HOT 10
- Finish adding abstract types and global constraints
- `-emacs` mode missing? HOT 4
- Semicolon allowed on last expression in block? HOT 1
- Tranlation of `foreach` from Sail to SystemVerilog failing. HOT 2
- Support class/struct-body output mode for C backend HOT 2
- Line number missing for cannot rewrite error HOT 3
- Failed to prove relatively simple constraint HOT 5
- `dune build` doesn't work due to warnings HOT 3
- Could not prove constraints in type synonym HOT 2
- Use type alias in constraints? HOT 2
- 64-bit system-specific C runtime libraries HOT 2
- Assertions don't change type of vars HOT 1
- Coq: Initial register values are not reflected in the generated coq code HOT 4
- New release? HOT 2
- SMT backend `return` bug? HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sail.