Skip to content

Basic canonicalize_expr of idents with tests #7806

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

Merged
merged 44 commits into from
Jun 10, 2025

Conversation

gamebox
Copy link
Collaborator

@gamebox gamebox commented May 23, 2025

This is just me getting this started and sharing things so that I can make sure I understand what we are trying to accomplish correct.

@gamebox gamebox requested review from smores56 and lukewilliamboswell and removed request for lukewilliamboswell May 23, 2025 17:50
Copy link
Collaborator

@lukewilliamboswell lukewilliamboswell left a comment

Choose a reason for hiding this comment

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

These changes look good. My only question is around how we will do snapshots for Can, but I'm sure we will get to that soon.

@lukewilliamboswell
Copy link
Collaborator

Ok, update on this.

I've gone ham on getting it compiling and the test passing again. I haven't made a pass over the changes in any great depth yet.

So I would consider this a WIP and not ready for merging right now. But it should be much easier to go through it now and fix issues.

Comment on lines +487 to +505
var items = collections.SafeList(CIR.Expr.Idx).initCapacity(self.can_ir.env.gpa, 0);
const items_slice = self.parse_ir.store.exprSlice(e.items);

for (items_slice) |item| {
if (self.canonicalize_expr(item)) |canonicalized| {
_ = items.append(self.can_ir.env.gpa, canonicalized);
}
}

const fresh_type_var = self.can_ir.type_store.fresh();

// Mark the start of scratch expressions for the list
const scratch_top = self.can_ir.store.scratchExprTop();

// Add all canonicalized items to scratch
var iter = items.iterIndices();
while (iter.next()) |idx| {
self.can_ir.store.addScratchExpr(items.get(idx).*);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason to have the allocation of items here? Can we just append straight to scratch?

const scratch_top = self.can_ir.store.scratchExprTop();

const items_slice = self.parse_ir.store.exprSlice(e.items);

for (items_slice) |item| {
  if (self.canonicalize_expr(item)) |canonicalized| {
    self.can_ir.store.addScratchExpr(canonicalized);
  }
}

Copy link
Contributor

@rtfeldman rtfeldman left a comment

Choose a reason for hiding this comment

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

I haven't reviewed this yet, but I think we can land it just to get something going on main. 😄

@rtfeldman rtfeldman merged commit f1654cc into roc-lang:main Jun 10, 2025
20 checks passed
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.

5 participants