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

Fix breaking change in builtin casts functions #327

Merged
merged 2 commits into from Jun 22, 2023

Conversation

lorrding
Copy link
Contributor

@lorrding lorrding commented Jun 22, 2023

While healing with Eowyn I noticed that two exercises are broken on latest build to date (0.11.0-dev.3747).

I looked up the doc and it seems that builtin casts functions changed name in a very recent build.

So instead of the old @enumToInt and @intToFloat we need to use @intFromEnum and @floatFromInt

This affects 036_enums2.zig and 096_memory_allocation.zig

Before breaking change:

ubuntu@temp:~/ziglings$ zig version
0.11.0-dev.3395+7b5bd3a93
ubuntu@temp:~/ziglings$ zig build -Dhealed -Dn=36
         _       _ _
     ___(_) __ _| (_)_ __   __ _ ___
    |_  | |/ _' | | | '_ \ / _' / __|
     / /| | (_| | | | | | | (_| \__ \
    /___|_|\__, |_|_|_| |_|\__, |___/
           |___/           |___/

    "Look out! Broken programs below!"

Compiling 036_enums2.zig...
Checking 036_enums2.zig...
PASSED:
<p>
  <span style="color: #ff0000">Red</span>
  <span style="color: #00ff00">Green</span>
  <span style="color: #0000ff">Blue</span>
</p>

Before fix:

ubuntu@temp:~/ziglings$ zig version
0.11.0-dev.3747+7b5bd3a93
ubuntu@temp:~/ziglings$ zig build -Dhealed -Dn=36
         _       _ _
     ___(_) __ _| (_)_ __   __ _ ___
    |_  | |/ _' | | | '_ \ / _' / __|
     / /| | (_| | | | | | | (_| \__ \
    /___|_|\__, |_|_|_| |_|\__, |___/
           |___/           |___/

    "Look out! Broken programs below!"

Compiling 036_enums2.zig...
error: the following command failed with 1 compilation errors:
/usr/bin/zig/zig build-exe /home/ubuntu/ziglings/exercises/036_enums2.zig --cache-dir /home/ubuntu/ziglings/zig-cache --listen=- 
exercises/036_enums2.zig:60:9: error: invalid builtin function: '@enumToInt'
        @enumToInt(Color.red),
        ^~~~~~~~~~~~~~~~~~~~~

Ziglings hint: I'm feeling blue about this.
Edit exercises/036_enums2.zig and run 'zig build -Dn=36' again.

After fix:

ubuntu@temp:~/ziglings$ zig version
0.11.0-dev.3747+7b5bd3a93
ubuntu@temp:~/ziglings$ zig build -Dhealed -Dn=36
         _       _ _
     ___(_) __ _| (_)_ __   __ _ ___
    |_  | |/ _' | | | '_ \ / _' / __|
     / /| | (_| | | | | | | (_| \__ \
    /___|_|\__, |_|_|_| |_|\__, |___/
           |___/           |___/

    "Look out! Broken programs below!"

Compiling 036_enums2.zig...
Checking 036_enums2.zig...
PASSED:
<p>
  <span style="color: #ff0000">Red</span>
  <span style="color: #00ff00">Green</span>
  <span style="color: #0000ff">Blue</span>
</p>

I hope I did everything right, I'm new to the repo and zig, so feel free to point out anything wrong

@chrboesch chrboesch merged commit 081669f into ratfactor:main Jun 22, 2023
11 checks passed
@chrboesch
Copy link
Collaborator

Thank you!

@lorrding
Copy link
Contributor Author

lorrding commented Jun 22, 2023

@chrboesch
I forgot to check for comments!

There's some comments especially in 065_builtins2.zig that are now outdated:

// ...and lots of type casting operations such as...
//
// @as @intToError @intToFloat
// @intToPtr @ptrToInt @enumToInt

I updated my branch, but you were quicker that I expected 😅 Do I need to make another PR ?
We need to update 036_enums2, 064_builtins and 065_builtins2

@chrboesch
Copy link
Collaborator

Do I need to make another PR ?

Everything works fine! 😄

vamega pushed a commit to vamega/ziglings that referenced this pull request Jul 25, 2023
Fix breaking change in builtin casts functions
fleimgruber pushed a commit to fleimgruber/ziglings that referenced this pull request Oct 26, 2023
Fix breaking change in builtin casts functions
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

Successfully merging this pull request may close these issues.

None yet

2 participants