Skip to content

Conversation

@JTrenerry
Copy link
Collaborator

@JTrenerry JTrenerry commented Jan 15, 2026

Adds a new ProcCheck to ensure type correctness of an IR program.

  • Change String.append to Printf.sprintf
  • Descriptive error messages
  • Write a test suite checking invalid types (Note: Some things are not tested i.e. calls since they fail at the parser and not the type checker)

@JTrenerry JTrenerry self-assigned this Jan 15, 2026
@JTrenerry JTrenerry mentioned this pull request Jan 15, 2026
3 tasks
@JTrenerry JTrenerry requested a review from agle January 16, 2026 03:43
@JTrenerry JTrenerry marked this pull request as ready for review January 16, 2026 04:03
open Expr
open Printf

type type_error = StatementEqualityError of { text : string }
Copy link
Owner

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.

Copy link
Owner

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.

Copy link
Collaborator Author

@JTrenerry JTrenerry Jan 16, 2026

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.

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)

Copy link
Owner

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

Copy link
Collaborator Author

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.

@JTrenerry
Copy link
Collaborator Author

todo: change return to use a pattern match instead of length for speed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants