-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Position information for backend errors #97
Comments
How about a function which takes
and then matches the ASTs against each other to find the location of the error in the simple AST and returns the concrete syntax location? Maybe there's even a 1-1 mapping between well-typed simple ASTs and refined ASTs (modulo locations)? In that case we should only need the last two arguments. |
hmmmm, the refined AST produced by the typechecker has a bunch of additional conditions attached to it by the |
I'm not sure I understand. I'm thinking like this:
I guess it's step 2 you see as problematic, but in that case my question is: What information are we throwing away in Alternatively, if my question seems misguided, what do you mean by "conditions attached to it"? |
hehe, I think I just hadn't fully understood your proposal 😀
I hadn't even considered this as a possibility. What would the algorithm look like? |
Something like this? But with waaaaay more cases. Kind of unsatisfactory in that way tbh... import Syntax
import RefinedAst
type ExpPos = [Int]
getRefinedPos :: ExpPos -> Exp a -> Expr -> Pn
getRefinedPos [] _ e = getPosn e
getRefinedPos (ix:ixs) refined simple = case ix of
0 -> case (refined,simple) of
(And e _, EAnd _ e' _) -> getRefinedPos ixs e e'
(Or e _, EOr _ e' _) -> getRefinedPos ixs e e'
_ -> error $ "no first argument in " <> show refined
1 -> case (refined,simple) of
(And _ e, EAnd _ _ e') -> getRefinedPos ixs e e'
(Or _ e, EOr _ _ e') -> getRefinedPos ixs e e'
_ -> error $ "no second argument in " <> show refined
2 -> case (refined,simple) of
(ITE _ _ e, EITE _ _ _ e') -> getRefinedPos ixs e e'
(Slice _ _ e, ESlice _ _ _ e') -> getRefinedPos ixs e e'
_ -> error $ "no third argument in " <> show refined |
But note that we don't need explicit cases for when What I'm conceptually unclear on at this point is some constructors of |
hmm, that option seems even more cumbersome than keeping around the position information in the refined context |
Yeah agreed tbh |
I guess one thing we could do is to create a inferExpr :: Env -> Expr -> Err ReturnExp becomes inferExpr :: Env -> Expr -> WriterT (Map ExpPos Pn) Err ReturnExp |
Parse / typecheck errors have nice position location, and can be pretty printed, however the position information is not passed down the chain pass the typechecker. This means that errors in the SMT backend (e.g. here), cannot provide a nice pretty printed output showing the user the source of the issue.
I'm not sure what the best way to deal with this is, dragging around the position information in the refined AST seems overly clunky. @kjekac @MrChico do you have any suggestions?
The text was updated successfully, but these errors were encountered: