Skip to content
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

Ch. 1 For loop example is not valid code #179

Closed
stringdom opened this issue Jun 12, 2023 · 2 comments
Closed

Ch. 1 For loop example is not valid code #179

stringdom opened this issue Jun 12, 2023 · 2 comments

Comments

@stringdom
Copy link

stringdom commented Jun 12, 2023

The following code used as example of a for loop does not compile on Zig 0.10.0 and therefore is not valid.

test "for" {
    //character literals are equivalent to integer literals
    const string = [_]u8{ 'a', 'b', 'c' };

    for (string, 0..) |character, index| {  // This line gives an error for the compiler expects ')' not a comma ',' after string.
        _ = character;
        _ = index;
    }

The compiler complaints that there cannot be a comma after the string type inside the for loop declaration.

I don't know if this is due to a change that's now valid in nightly 0.11 but it does raises the question, what should the documentation be targeting. The moving nightly or a previous stable version. However not yet very well defined that concept might be right now.

@Drakx
Copy link

Drakx commented Jun 15, 2023

I'm getting the same issue with stable

@stringdom
Copy link
Author

I just noticed that Ch. 0 states that the latest version of Zig is 0.10.1 then later on, in the installation instructions, suggests that the user should see an output to zig version of 0.11.0-dev.2777+b95cdf0ae after following the install procedure.

Which means that currently ziglearn tests and compiles correctly on zig-0.11.0-dev.3395+1e7dcaa3a but does not on 0.10.1

From the Zig-lang.org webpage:

Latest Release: 0.10.1

I think the user should be instructed to install the latest release, not the nightly development version.
But, it seems there's no interest on discussing this?

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

No branches or pull requests

3 participants