-
Notifications
You must be signed in to change notification settings - Fork 3
Type checker #15
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
base: main
Are you sure you want to change the base?
Type checker #15
Conversation
lib/transforms/type_check.ml
Outdated
| open Expr | ||
| open Printf | ||
|
|
||
| type type_error = StatementEqualityError of { text : string } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name this as just TypeError or something, it would be nice to be more precise than a string but its fine for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conventionally you would also define a show_type_error type_error -> string function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name this as just
TypeErroror something, it would be nice to be more precise than a string but its fine for now.
Okay, originally I did have stmt as well, but without position (within the stmt or the stmt in the ir) its strange.
(Could probably make this have stmt and stmt number (within a block) and block number, but unsure if there is a set order)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah at some point I'll need to set up the IR to pass through text locations from the parser for better error messages, for now i generally just use (block_id, stmt num) with stmt num being whats given by List.mapi ie indexes counting from zero
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this, but I moved a lot of functions under type_check which makes it pretty ugly, but was the easiest / nicest way I could think of passing the ids around without ruining the folds.
|
todo: change return to use a pattern match instead of length for speed. |
Adds a new ProcCheck to ensure type correctness of an IR program.