Comments (9)
I just ran into this too 👀 and was stuck for a while.
going back to exercises on methods seem to explain what is going on here 😆
from ziglings.
Okay everybody, I think I've improved it. I didn't fully realize how misleading and confusing the hints were on that one until I went in to fix it. Here it is now:
// Oh dear, we seem to have done something wrong when calling
// this function. We called it as a method, which would work
// if it had a self parameter. But it doesn't. (See above.)
//
// The fix for this is very subtle, but it makes a big
// difference!
const Type2 = narcissus.fetchTheMostBeautifulType();
I hope it's much clearer now that we want to change the calling site, not the declaration! Thanks for all the helpful comments on this issue!
from ziglings.
@ricardomatias I just ran my checker script against the latest copy of Ziglings using a fresh snapshot of Zig:
$ zig version
0.10.0-dev.3394+1a1b7a3af
Compiling 065_builtins2.zig...
Checking 065_builtins2.zig...
PASSED:
A Narcissus loves all Narcissuses. He has room in his heart for: me myself.
That line 56 looks current. And it should check your minimum Zig version. Hmmmm... Oh, I think there was an instance where somebody was running a new version of Zig, but an old version of the standard library. Maybe it's something like that?
Could you paste the result of zig env
?
Here's mine:
$ zig env
{
"zig_exe": "/home/dave/zig/zig",
"lib_dir": "/home/dave/zig/lib",
"std_dir": "/home/dave/zig/lib/std",
"global_cache_dir": "/home/dave/.cache/zig",
"version": "0.10.0-dev.3394+1a1b7a3af"
}
from ziglings.
I have encountered same problem. Windows, Zig is 0.10.0-dev.3475+b3d463c9e.
On a side note, I think it uses local zig-cache in repo folder, not global one.
Even fiddling with official @This()
example sometimes gives that error, so probably it's language issue
Btw, my understanding that you need to add (self: Narcissus)
parameter, but it will complain about self
not used, and supressing with _ = self
explained only in Ex70. (I just happen to know this from somewhere)
from ziglings.
@ratfactor sorry for the late reply.. here it is:
{
"zig_exe": "C:\\Users\\Ricardo\\scoop\\apps\\zig-dev\\current\\zig.exe",
"lib_dir": "C:\\Users\\Ricardo\\scoop\\apps\\zig-dev\\current\\lib",
"std_dir": "C:\\Users\\Ricardo\\scoop\\apps\\zig-dev\\current\\lib\\std",
"global_cache_dir": "C:\\Users\\Ricardo\\AppData\\Local\\zig",
"version": "0.10.0-dev.3394+1a1b7a3af"
}
from ziglings.
Wild. I do have a Windows desktop here I can test on.
from ziglings.
@realgdman Well, a self
parameter should not be required to complete this one. I'm looking for a solution that uses builtins. You can peek at patches/patches/065_builtins2.patch
to see what's expected.
Actually, @ricardomatias, this did not occur to me before for some reason, but could you check your answer versus the "official" answer ☝️? Thanks!
It's possible that what's expected in this exercise is not clear, in which case it may need some fixing to make it more clear!
from ziglings.
@ratfactor oh I got it, I misunderstand wording about "self parameter" and was fixing declaration instead of call.
from ziglings.
@realgdman Thanks for that. Clearly the wording on this one needs a little help!
from ziglings.
Related Issues (20)
- Use `role` instead of `class` for struct related exercises HOT 1
- error on build with latest zig 0.11.0-dev.4229 HOT 1
- 062_loop_expressions comptime-only type error HOT 1
- expected 2 arguments and 1 found HOT 6
- Explain abbreviation `lhs`
- 101: More details for SoA vs AoS HOT 4
- Exercise 18 fails in new version (0.12.0) HOT 2
- How do you prevent ziglings from running previously solved exercises? HOT 4
- Zigling 045 HOT 1
- [Exercise 48] Can anyone explain what is happening here? HOT 1
- Announcement! We've moved to Codeberg HOT 16
- Excercise to perform input via console HOT 1
- Ziglings broken by latest Master HOT 2
- Understanding Exercise 40 note
- Failing compilation for 0.12.0-dev.1632+acf9de376 HOT 2
- Set up GitHub mirror HOT 6
- Cannot build with "zig build" HOT 4
- Mistake in 094? HOT 2
- exercise/065_builtins2.zig not compiling HOT 2
- Adding JSON & Hashmap Ziglings HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ziglings.