Skip to content
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

Refactored SymbolTable and related changes. #28488

Merged
merged 1 commit into from
Jan 23, 2025
Merged

Conversation

mikebenfield
Copy link
Collaborator

@mikebenfield mikebenfield commented Jan 21, 2025

The SymbolTable design is now a little simpler, and local scopes don't have tables to store functions, structs, etc, since those are only globals anyway.

With this PR we:

  • Remove the symbol table json code.
  • Revise code catching assignments in conditionals in async functions. Previously, code like this:
if x {
  let y: u8 = 1u8;
  {
    y = 2u8;
  }
}

would trigger the error, but it should actually pass.

  • Can use locators for local records and mappings
  • Remove the N type parameter in TypeChecker. Instead, we have a NetworkLimits struct which contains the values the TypeChecker will actually use. This cuts down on code bloat a bit.

@mikebenfield mikebenfield requested a review from d0cd January 21, 2025 16:59
@mikebenfield mikebenfield force-pushed the symbol-table-squash branch 2 times, most recently from 8810f56 to aeabc3a Compare January 21, 2025 17:51
@@ -1008,6 +1009,6 @@ impl<'a, N: Network> ExpressionVisitor<'a> for TypeChecker<'a, N> {
}

fn visit_unit(&mut self, _input: &'a UnitExpression, _additional: &Self::AdditionalInput) -> Self::Output {
unreachable!("Unit expressions should not exist in normal code");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe unit expression should not exist at this point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They actually do exist (not explicitly specified by the user) in return statements. At least for now I'll leave this as is.

Copy link
Collaborator

@d0cd d0cd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the design of the new symbol table and it greatly simplifies scope management, while addressing a number of issues. I left a few comments and nits, otherwise LGTM!

@mikebenfield mikebenfield force-pushed the symbol-table-squash branch 2 times, most recently from 1d47458 to 6673a94 Compare January 22, 2025 23:06
The SymbolTable design is now a little simpler, and local scopes
don't have tables to store functions, structs, etc, since those
are only globals anyway.

Remove the symbol table json code.

Revise code catching assignments in conditionals in async functions.
Previously, code like this:

if x {
  let y: u8 = 1u8;
  {
    y = 2u8;
  }
}

would trigger the error, but it should actually pass.

Can use locators for local records and mappings

Remove the N type parameter in TypeChecker. Instead, we have a
`NetworkLimits` struct which contains the values the TypeChecker
will actually use. This cuts down on code bloat a bit.
@mikebenfield mikebenfield merged commit 72a9acc into mainnet Jan 23, 2025
10 checks passed
@mikebenfield mikebenfield deleted the symbol-table-squash branch January 23, 2025 17:41
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.

2 participants