Skip to content

Conversation

@wmccrthy
Copy link
Contributor

No description provided.

Comment on lines 268 to 270
- upwards navigation is rly useful; in this codemod, it'd be a lot easier / more performant to query for each function call (generally), update all those that are migrated accordingly (if we have upwards nav
we can get the statement by walking up tree from the call node). unfortunately, bc some of the migrations require the whole call statement (i.e local var = call),
we cannot do this and have to query for statements for those transforms that require the whole statement context, and separately query for calls for those transforms that only need the call node

Choose a reason for hiding this comment

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

Just cut #593: I agree.

Comment on lines 272 to 275
- I'm not sure of a good way around this one, just a general performance concern, it's tricky to vary operations between node world / string world.
When operating on a node, it is not uncommon to want to re-use parts of that node in your transformed output; currently, this will require:
- for string transform: parsing the node into a string, and interpolating into your returned replacement
- for node transform: cloning node so it's mutable, updating accordingly (even more impractical, would never do this, just pointing out you CAN)

Choose a reason for hiding this comment

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

I think we should be biasing towards string transforms. Most codemods are going to be one-and-done, not multi-pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, writing the string transforms was much nicer for this. I guess my point here is that i'm curious if there's a better way to keep parts of existing nodes than using printer

@wmccrthy wmccrthy requested a review from hgoldstein November 21, 2025 01:57
end
end)
end
end)

Choose a reason for hiding this comment

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

You should check out fs.walk if it's available: I think that's going to be more consistent for your use cases.

Choose a reason for hiding this comment

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

Bumping this: I think you want fs.walk here.

This definitely looks like this can be abstracted as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's the main difference you're envisioning? The logic has to be kinda specific since the test cases are all in a flat dir, i.e:

  • we walk the directory with all cases; we find case1.luau. We need to match this specifically too case1.luau.result, case1.luau.expect. I'm not sure walking makes this any easier?

I've reformatted to use fs.walk, but lmk if there's a different structure you're looking for.

Choose a reason for hiding this comment

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

You could imagine for a larger golden test you have a lot of different subdirectories with different kinds of tests, and maybe different settings for each test.

Comment on lines 37 to 53
local subcase = v.name
local subcaseBasePath = path.format(path.join(transformCasesPath, subcase))
local initialPath = path.format(path.join(subcaseBasePath, "initial.luau"))
local expectedPath = path.format(path.join(subcaseBasePath, "expected.luau"))
local resultPath = path.format(path.join(subcaseBasePath, "result.luau"))

local initialSrc = fs.readfiletostring(initialPath)

formattedTransform(initialPath, expectedPath, transformPath)

local result = fs.readfiletostring(initialPath)
fs.writestringtofile(resultPath, result)
fs.writestringtofile(initialPath, initialSrc)

local expectedResult = fs.readfiletostring(expectedPath)

assert.eq(result, expectedResult)

Choose a reason for hiding this comment

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

  1. We already spoke offline about changing the structure here.
  2. You should think about what happens if a given test doesn't conform to the expected structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On one hand, we could use git diff via a process, but it feels kinda weird to not use an in-house solution. Maybe write a very basic diffing system that compares the output vs snapshot line-by-line?

@wmccrthy wmccrthy requested a review from hgoldstein December 9, 2025 01:11
end
end)
end
end)

Choose a reason for hiding this comment

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

Bumping this: I think you want fs.walk here.

This definitely looks like this can be abstracted as well.


-- convert calls
local callRepl = query
.findallfromroot(ast, queryUtils.isExprCall)

Choose a reason for hiding this comment

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

cc @skberkeley: maybe we should move the query utils to query; feels kinda silly that you have to import both.

callRepl,
libIndexNameRepl,
libIndexExprRepl,
addedRequiresRepl :: types.replacements

Choose a reason for hiding this comment

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

what happened here?

Copy link
Contributor Author

@wmccrthy wmccrthy Dec 10, 2025

Choose a reason for hiding this comment

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

Getting: TypeError: No valid instantiation could be inferred for generic type parameter K. on tableext.combine unless I cast this last value to replacements. Even seeing the error if I cast each individual declaration for these variables to replacements

@wmccrthy wmccrthy marked this pull request as ready for review December 10, 2025 19:35
@wmccrthy wmccrthy requested a review from hgoldstein December 10, 2025 19:35
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