You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current test code snippet, when executed using zig build-exe, displays a confusing error message due to a mismatch in usage. This is because zig build-exe expects an entry point with a main function, which is not present in the test file.
Current Output
Using zig build-exe on 15-errors-switch.zig results in the following error, which is uninformative for new users:
$ zig build-exe 15-errors-switch.zig
/home/ci/deps/zig-linux-x86_64-0.13.0/lib/std/start.zig:509:45: error: root struct of file '15-errors-switch' has no member named 'main'
switch (@typeInfo(@typeInfo(@TypeOf(root.main)).Fn.return_type.?)) {
~~~~^~~~~
/home/ci/actions-runner-website/_work/www.ziglang.org/www.ziglang.org/assets/zig-code/features/15-errors-switch.zig:1:1: note: struct declared here
const std = @import("std");
^~~~~
/home/ci/deps/zig-linux-x86_64-0.13.0/lib/std/start.zig:482:20: note: called from here
returncallMain();
~~~~~~~~^~
/home/ci/deps/zig-linux-x86_64-0.13.0/lib/std/start.zig:438:36: note: called from here
std.posix.exit(callMainWithArgs(argc, argv, envp));~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
referenced by:
_start: /home/ci/deps/zig-linux-x86_64-0.13.0/lib/std/start.zig:351:40
remaining reference traces hidden; use '-freference-trace' to see all reference traces
Suggested Solution
Running the file as a test with zig test provides a much clearer, relevant output. This clarifies the specific error being tested in 15-errors-switch.zig and would be more helpful for learners.
Expected Output
Using zig test 15-errors-switch.zig gives meaningful feedback regarding the issue:
Update the documentation and code snippets on the overview page to specify using zig test instead of zig build-exe for 15-errors-switch.zig. This will ensure that learners receive relevant error information and improve clarity on Zig's error handling capabilities.
The text was updated successfully, but these errors were encountered:
dmitry-j-mikhin
changed the title
15-errors-switch.zig test on ziglang.org/learn/overview/ shows wrong output
Incorrect Output for 15-errors-switch.zig on https://ziglang.org/learn/overview/
Oct 30, 2024
https://ziglang.org/learn/overview/:
Issue Summary
The current test code snippet, when executed using
zig build-exe
, displays a confusing error message due to a mismatch in usage. This is becausezig build-exe
expects an entry point with amain
function, which is not present in the test file.Current Output
Using
zig build-exe
on15-errors-switch.zig
results in the following error, which is uninformative for new users:Suggested Solution
Running the file as a test with
zig test
provides a much clearer, relevant output. This clarifies the specific error being tested in15-errors-switch.zig
and would be more helpful for learners.Expected Output
Using
zig test 15-errors-switch.zig
gives meaningful feedback regarding the issue:Resolution Suggestion
Update the documentation and code snippets on the overview page to specify using
zig test
instead ofzig build-exe
for15-errors-switch.zig
. This will ensure that learners receive relevant error information and improve clarity on Zig's error handling capabilities.The text was updated successfully, but these errors were encountered: