Further improved include error messages #2265
Open
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.
What does this PR do?
This is a continuation of my previous PR (CC @samsinsane - it's me again sorry!), improving the error message output for
include()
a bit, making it more precise and with less redundancy. I've also given the same love I gave toinclude()
toincludeexternal()
, since it's essentially the same function.How does this PR change Premake's behavior?
includeexternal()
did not used to return the result of executing the included script, whereasinclude()
did. I believe this was an oversight, as the documentation states thatincludeexternal()
"works just likeinclude()
". I don't see this change causing harm since it was previously not returning any value, so I doubt there's any code relying on it returning nil. I have run the unit tests to be sure, and they're all green.Example of an error from an include directly in the root premake5.lua
Error: ** Error: D:\dev\build-sys-eval\foobar\src\premake5.lua(36): include($/self-test/test_declare.lua) execution error: [string "self-test/test_declare.lua"]:6: attempt to index a nil value (local 'm')
Examples of errors from nested includes, with multiple-levels of include context
Example output of a missing include file:
Error: ** Error: D:\dev\build-sys-eval\foobar\src\premake5.lua(33): include(tools/premake/badcode.lua) execution error: ** Error: D:\dev\build-sys-eval\foobar\src\tools\premake\badcode.lua(1): include(no-file-here) not found or failed to load: ** Error: Cannot find neither no-file-here nor no-file-here.lua nor no-file-here/premake5.lua nor no-file-here/premake4.lua
Example output of a syntax error in an include file:
Error: ** Error: D:\dev\build-sys-eval\foobar\src\premake5.lua(21): include(foobar/L1a) not found or failed to load: ** Error: Error loading 'foobar/L1a: D:/dev/build-sys-eval/foobar/src/foobar/L1a/premake5.lua:8: syntax error near ']'
Example output of an incorrectly loaded internal script:
Error: ** Error: D:\dev\build-sys-eval\foobar\src\foobar\L1a\premake5.lua(30): include(tools/premake/badcode.lua) execution error: ** Error: D:\dev\build-sys-eval\foobar\src\tools\premake\badcode.lua(59): include($/self-test/test_declare.lua) execution error: [string "self-test/test_declare.lua"]:6: attempt to index a nil value (local 'm')
Anything else we should know?
n/a
Did you check all the boxes?
closes #XXXX
in comment to auto-close issue when PR is merged)