Fix infinite recursion in ignore#540
Merged
Nicell merged 4 commits intoluau-lang:primaryfrom Nov 7, 2025
Merged
Conversation
Vighnesh-V
requested changes
Nov 7, 2025
Collaborator
Vighnesh-V
left a comment
There was a problem hiding this comment.
small change, but otherwise looks good to me.
Vighnesh-V
approved these changes
Nov 7, 2025
skberkeley
reviewed
Nov 7, 2025
| local function parseGitignore(filepath: path.path): GitignoreData | ||
| local contents = fs.readfiletostring(path.format(filepath)) | ||
| return parseGitignoreContents(assert(path.dirname(filepath)), contents) | ||
| local parentDirectory = if path.basename(filepath) then path.dirname(filepath) else nil |
Contributor
There was a problem hiding this comment.
we have path.path objects, so I believe the following would be more performant:
if #path.parts > 0 then path.dirname(filepath) else nil
Contributor
Author
There was a problem hiding this comment.
If filePath is always a table here, won't path.basename mirror this exact logic (non-nil if #path.parts > 0 and nil otherwise)? Happy to change but curious what the performance bottleneck would be
Contributor
There was a problem hiding this comment.
yeah, the logic will be the same, but we avoid the table check and passing the string basename around this way
skberkeley
approved these changes
Nov 7, 2025
Nicell
approved these changes
Nov 7, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ignorewas recently ported over from a different repo, that used an adhocpathimplementation. This repo'spath.dirnamereturned a string or nil, but lute'spath.dirnamealways returns a string.On various occasions in
ignore( one example here), we gate continued processing behind checks thatpath.dirname(arbitrary)exists. These are all invalid checks now and in some of these cases, we recur leading to death by stack overflow.This PR fixes aforementioned checks, using
path.basename(returns string | nil if at root) to determine if the current path is the root.I found this bug when encountering a stack overflow error while trying to use
lute transform:I rebuilt lute with these changes and
transformworked as expected.