Comments (3)
Better solution: create a function getErrorNode : Exp -> astId
that takes an expression and returns the correct error location for type errors of that expression.
A block returns the last line of the block
A function could return its own name, or maybe a specific type argument if that is return type for the function (or it could keep being just the full expression)
Other expressions should just return themselves.
Example implementation
getErrorNode(exp) = astId(exp).
getErrorNode(Call(_, name, _, _)) = astId(name). // good idea?
getErrorNode(QCall(_, name, _, _)) = astId(name). // good idea?
getErrorNode(exp@Block([])) = astId(exp).
getErrorNode(Block(lines)) = getLastLine(lines).
getLastLine : list(Exp) -> Exp
getLastLine([exp]) = astId(exp).
getLastLine([_|rest@[_|_]]) = getLastLine(rest).
from pie.
Given higher priority because this makes it harder to solve the root cause of the incorrect return type (the actual error cannot easily be spotted because the whole block is red)
from pie.
Note: using astid
s as error locations currently does not work, see metaborg/nabl#74
from pie.
Related Issues (20)
- Make _ an anonymous value HOT 4
- Give warnings when type parameters do not have multiple solutions
- Give warning when two type parameters cannot be inequal
- Parse function declarations without equals sign
- Add list with explanations of editor messages
- Replace EmptyList with list of bottom type
- Useful link with explanation of subtyping in Kotlin?
- Replace NullType with NullableType(BottomType())
- Incorrect documentation: nullable types cannot access methods of inner type
- Use wildcards for least upper bound of two lists
- Bug in code generation
- List literal compilation should specify the generic arguments
- Least upper bound nullable relies on subtyping
- Use Statix incremental solver HOT 1
- Document meanings of message severities
- Generate valid Java code from invalid PIE code
- Annotation to suppress messages
- Let parsing recover from no expression after a ;
- Value declaration compiles to unit
- Add tests suffering from bug
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 pie.