-
Couldn't load subscription status.
- Fork 28
stdlib: loadbypath #461
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
stdlib: loadbypath #461
Conversation
|
Also will resolve #463 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements requirebypath (renamed to loadbypath) in userland using luau.load and fixes a bug in the path library where path objects were being mutated during path.join operations.
Key Changes:
- Added
luau.loadbypathfunction to load and execute Luau scripts by file path - Fixed path mutation bug by cloning path objects in
path.joinfor both POSIX and Win32 implementations - Updated require statements from
@lute/luauto@std/luauacross multiple files
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lute/std/libs/luau.luau | New wrapper module implementing loadbypath and re-exporting types from @lute/luau |
| lute/std/libs/path/posix.luau | Fixed path mutation by cloning path parts before joining |
| lute/std/libs/path/win32.luau | Fixed path mutation by cloning path parts before joining |
| tests/loadbypath.test.luau | Integration test verifying loadbypath functionality |
| tests/path.posix.test.luau | Added assertions to verify original path object remains unchanged after join |
| tests/path.win32.test.luau | Added assertions to verify original path object remains unchanged after join |
| lute/luau/src/luau.cpp | Simplified C++ implementation by removing redundant path manipulation logic |
| definitions/luau.luau | Updated luau.load signature to make chunkname parameter non-optional |
| tests/testAstSerializer.test.luau | Updated imports to use @std/luau |
| lute/std/libs/syntax/visitor.luau | Updated imports to use @std/luau |
| lute/std/libs/syntax/printer.luau | Updated imports to use @std/luau |
| lute/std/libs/syntax/parser.luau | Updated imports to use @std/luau |
| examples/parsing.luau | Updated imports to use @std/luau |
| examples/linter.luau | Updated imports to use @std/luau |
| examples/compile.luau | Updated imports to use @std/luau |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| export type Position = luteLuau.Position | ||
| export type Location = luteLuau.Location | ||
|
|
||
| export type Whitespace = luteLuau.Whitespace | ||
| export type SingleLineComment = luteLuau.SingleLineComment | ||
| export type MultiLineComment = luteLuau.MultiLineComment | ||
|
|
||
| export type Trivia = luteLuau.Trivia | ||
|
|
||
| export type Token<Kind = string> = luteLuau.Token<Kind> | ||
|
|
||
| export type Eof = luteLuau.Eof | ||
|
|
||
| export type Pair<T, Separator> = luteLuau.Pair<T, Separator> | ||
| export type Punctuated<T, Separator = ","> = luteLuau.Punctuated<T, Separator> | ||
|
|
||
| export type AstLocal = luteLuau.AstLocal | ||
|
|
||
| export type AstExprGroup = luteLuau.AstExprGroup | ||
|
|
||
| export type AstExprConstantNil = luteLuau.AstExprConstantNil | ||
|
|
||
| export type AstExprConstantBool = luteLuau.AstExprConstantBool | ||
|
|
||
| export type AstExprConstantNumber = luteLuau.AstExprConstantNumber | ||
|
|
||
| export type AstExprConstantString = luteLuau.AstExprConstantString | ||
|
|
||
| export type AstExprLocal = luteLuau.AstExprLocal | ||
|
|
||
| export type AstExprGlobal = luteLuau.AstExprGlobal | ||
|
|
||
| export type AstExprVarargs = luteLuau.AstExprVarargs | ||
|
|
||
| export type AstExprCall = luteLuau.AstExprCall | ||
|
|
||
| export type AstExprIndexName = luteLuau.AstExprIndexName | ||
|
|
||
| export type AstExprIndexExpr = luteLuau.AstExprIndexExpr | ||
|
|
||
| export type AstFunctionBody = luteLuau.AstFunctionBody | ||
|
|
||
| export type AstExprAnonymousFunction = luteLuau.AstExprAnonymousFunction | ||
|
|
||
| export type AstExprTableItem = luteLuau.AstExprTableItem | ||
|
|
||
| export type AstExprTable = luteLuau.AstExprTable | ||
|
|
||
| export type AstExprUnary = luteLuau.AstExprUnary | ||
|
|
||
| export type AstExprBinary = luteLuau.AstExprBinary | ||
|
|
||
| export type AstExprInterpString = luteLuau.AstExprInterpString | ||
|
|
||
| export type AstExprTypeAssertion = luteLuau.AstExprTypeAssertion | ||
|
|
||
| export type AstExprIfElseIfs = luteLuau.AstExprIfElseIfs | ||
|
|
||
| export type AstExprIfElse = luteLuau.AstExprIfElse | ||
|
|
||
| export type AstExpr = luteLuau.AstExpr | ||
|
|
||
| export type AstStatBlock = luteLuau.AstStatBlock | ||
|
|
||
| export type AstStatElseIf = luteLuau.AstStatElseIf | ||
|
|
||
| export type AstStatIf = luteLuau.AstStatIf | ||
|
|
||
| export type AstStatWhile = luteLuau.AstStatWhile | ||
|
|
||
| export type AstStatRepeat = luteLuau.AstStatRepeat | ||
|
|
||
| export type AstStatBreak = luteLuau.AstStatBreak | ||
|
|
||
| export type AstStatContinue = luteLuau.AstStatContinue | ||
|
|
||
| export type AstStatReturn = luteLuau.AstStatReturn | ||
|
|
||
| export type AstStatExpr = luteLuau.AstStatExpr | ||
|
|
||
| export type AstStatLocal = luteLuau.AstStatLocal | ||
|
|
||
| export type AstStatFor = luteLuau.AstStatFor | ||
|
|
||
| export type AstStatForIn = luteLuau.AstStatForIn | ||
|
|
||
| export type AstStatAssign = luteLuau.AstStatAssign | ||
|
|
||
| export type AstStatCompoundAssign = luteLuau.AstStatCompoundAssign | ||
|
|
||
| export type AstAttribute = luteLuau.AstAttribute | ||
|
|
||
| export type AstStatFunction = luteLuau.AstStatFunction | ||
|
|
||
| export type AstStatLocalFunction = luteLuau.AstStatLocalFunction | ||
|
|
||
| export type AstStatTypeAlias = luteLuau.AstStatTypeAlias | ||
|
|
||
| export type AstStatTypeFunction = luteLuau.AstStatTypeFunction | ||
|
|
||
| export type AstStat = luteLuau.AstStat | ||
|
|
||
| export type AstGenericType = luteLuau.AstGenericType | ||
|
|
||
| export type AstGenericTypePack = luteLuau.AstGenericTypePack | ||
|
|
||
| export type AstTypeReference = luteLuau.AstTypeReference | ||
|
|
||
| export type AstTypeSingletonBool = luteLuau.AstTypeSingletonBool | ||
|
|
||
| export type AstTypeSingletonString = luteLuau.AstTypeSingletonString | ||
|
|
||
| export type AstTypeTypeof = luteLuau.AstTypeTypeof | ||
|
|
||
| export type AstTypeGroup = luteLuau.AstTypeGroup | ||
|
|
||
| export type AstTypeOptional = luteLuau.AstTypeOptional | ||
|
|
||
| export type AstTypeUnion = luteLuau.AstTypeUnion | ||
|
|
||
| export type AstTypeIntersection = luteLuau.AstTypeIntersection | ||
|
|
||
| export type AstTypeArray = luteLuau.AstTypeArray | ||
|
|
||
| export type AstTypeTableItem = luteLuau.AstTypeTableItem | ||
|
|
||
| export type AstTypeTable = luteLuau.AstTypeTable | ||
|
|
||
| export type AstTypeFunctionParameter = luteLuau.AstTypeFunctionParameter | ||
|
|
||
| export type AstTypeFunction = luteLuau.AstTypeFunction | ||
|
|
||
| export type AstType = luteLuau.AstType | ||
|
|
||
| export type AstTypePackExplicit = luteLuau.AstTypePackExplicit | ||
|
|
||
| export type AstTypePackGeneric = luteLuau.AstTypePackGeneric | ||
|
|
||
| export type AstTypePackVariadic = luteLuau.AstTypePackVariadic | ||
|
|
||
| export type AstTypePack = luteLuau.AstTypePack | ||
|
|
||
| export type ParseResult = luteLuau.ParseResult | ||
|
|
||
| export type Bytecode = luteLuau.Bytecode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all of these should become luacase ultimately, but it's okay if that doesn't happen in this PR.
|
I don't want to be annoying lol, but I think i'm going to ask that we separate the path.join fix since it's affecting at least a few lute users and we should deliver that faster (it's also uncontroversial). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I would just be sure to rename the PR title and description with the new API name.
Implementation of
loadbypathin user land usingluau.load. Addresses #321 .