<daurnimator>
fengb_: no. the `2` by itself is a comptime_int. your other branches you e.g. add it to a known int type, so the comptime gets casted away
<tiehuis>
zig will likely analyze the branch as returning a comptime_int, try to compute the value but the branch is runtime-known so it emits an error
<tiehuis>
when you use a cast it analyzes the branch as returning a usize which has a fixed size and works fines
<fengb_>
Ah okay thanks
tiehuis has quit [Quit: WeeChat 2.4]
emekankurumeh[m] has joined #zig
<emekankurumeh[m]>
does zig support compiling to arm cortex?
<daurnimator>
emekankurumeh[m]: yes?
<daurnimator>
emekankurumeh[m]: run `zig targets` and pick the relevant arm option for your processor.
<emekankurumeh[m]>
would the target name be different from the processor name?
<daurnimator>
emekankurumeh[m]: what is the processor name?
<daurnimator>
emekankurumeh[m]: note that there are hundreds of different arm cortex varieties. all with different features
<daurnimator>
emekankurumeh[m]: also note that arm has had a history of many different abis
<emekankurumeh[m]>
the arm cortex m4
<daurnimator>
and then you have the question of full arm vs thumb vs thumb2...
<emekankurumeh[m]>
its the teensy 3.5 if that helps
<daurnimator>
emekankurumeh[m]: so you have the arm-v7em architecture or thumb-v7em. you probably are freestanding. you probably want to use eabihf (hf = hard float)
<shritesh>
That page is being generated by Zig (with some JS shim). It uses the @embedFile builtin to embed it's own source code. So technically it's a Zig/WASM quine
<shritesh>
I intend to have the JS shim be autogenerated by the compiler
<tyler569>
and I just booted a Linux kernel with a pure-zig userland! https://i.imgur.com/exEYP9H.png - let's just say it's a little minimal ^.^
<shritesh>
tyler569: That's awesome!!!
<emekankurumeh[m]>
ok, now i understand
<emekankurumeh[m]>
the extern functions at the top are referencing symbols from the javascript side
<hryx>
daaaaaang tyler569
<tyler569>
it's not all that impressive, trust me :P, std.debug.warn oneliner basically
<tyler569>
just gotta wrap it up in an initrd
<tyler569>
grub config
<tyler569>
boom
<fengb_>
Hmm, is there a reason why for/else isn't for/catch?
<mikdusan>
the `else` isn't an error and catch implies error
<shritesh>
Next up: Virtual DOM in Zig
<fengb_>
"When the else |x| syntax is present on a while expression, the while condition must have an Error Union Type."
<fengb_>
Oh it mirrors if semantics for error unions
ltriant has joined #zig
ltriant has quit [Ping timeout: 255 seconds]
<hryx>
ok, playing around with this failing allocator in the parser test. I understand it a little better now. Very cool way of getting thorough coverage!
<hryx>
This tiny test I added has a maximum fail_index of 3. If I start the fail index counter at a number other than 0 I can test the Nth allocation
<hryx>
allocations 0 and 3 always succeed, but 1 and 2 always fail
<hryx>
(rather, the bytes freed != bytes allocated as andrew pointed earlier)
<hryx>
Just dumping my findings here on the off chance it sparks any ideas. I'll continue sleuthing meantime!
<hryx>
Er, there is no allocation #3. only 0 through 2. So only the first one succeeds, probably because all allocations fail, so nothing can get freed anyway
ltriant has joined #zig
ltriant has quit [Ping timeout: 268 seconds]
<daurnimator>
do we have any coverage tools for zig?
<ljmccarthy>
not sure if I'm reinventing something zig already has
<ljmccarthy>
also it's not clear if it's valid to return the address of a comptime array I've allocated locally or not
mht has joined #zig
ltriant has joined #zig
ltriant has quit [Ping timeout: 250 seconds]
neceve has joined #zig
ljmccarthy has quit []
ManDeJan has quit [Ping timeout: 250 seconds]
Barabas has joined #zig
<Barabas>
I'm trying to build zig (master) and it says: /usr/bin/ld: cannot find -ltinfo
<Barabas>
On linux (mxlinux) and when I search for libtinfo in synapic it notes for libtinfo-dev:
<Barabas>
This package contains the static library and symbolic link that developers using the low-level terminfo library will need. Packages should not build-depend on this package.
<Barabas>
Is it fine to link against or not? I'm confused.
<Barabas>
To be clear. It works when I install libtinfo-dev, so that's fine. I'm just confused. ^^
Barabas has quit [Ping timeout: 256 seconds]
mht has quit [Ping timeout: 250 seconds]
<bketelsen>
shritesh: holy moly DOM access!
<shritesh>
bketelsen: It's still too verbose. I've been studying how other ecosystems handle interop and I think I have a few good ideas to make Zig the best platform to write WASM for the browser.
<shritesh>
But hey, it works :D
<bketelsen>
i'm 100% here for this, would love to collaborate
<shritesh>
That'd be awesome!
<bketelsen>
what is the "document" in the first part of this line: "extern "document" fn query_selector(selector_ptr: [*]u8, selector_len: usize) usize;
<bketelsen>
"
<bketelsen>
is that a namespace?
<shritesh>
That's a webassembly module name
<shritesh>
By default it's "env" but I love namespaces
<shritesh>
Event listeners can be attached at runtime to nodes.
<shritesh>
Alsi, our work is easier because Zig has manual memory management and expects the programmer to dealloc. A lot of complexity in wasm-bindgen stems from having the compiler manually deallocate memory
<shritesh>
'also
<bketelsen>
another question "return error.QuerySelectorError" <-- I don't see these errors actually defined anywhere
<bketelsen>
is that a zig thing I don't know?
<shritesh>
Zig maintains a global union of all errors
<andrewrk>
I think your example needs a type because how is it supposed to know the upper bound? you could have chosen anything instead of 10 and that's at some unknown future code
<andrewrk>
TheLemonMan, oh I see, it's error: invalid character: ')' which is unhelpful because you can't see the file contents
<andrewrk>
I'll take a look on my macos laptop when I examine your pull request
<TheLemonMan>
great, thank you
<andrewrk>
shritesh, ah, yeah I haven't merged this because I want to understand why it can't be solved in a more generic way, it's not intended to have to explicitly write code for these types
<andrewrk>
alright I need to have another day where I'm mostly offline
<andrewrk>
next week/weekend is going to be crazy for me, and then I should be back in the swing of things the week after
<bketelsen>
shritesh: it might be simple enough to do an event proxy on the JS side that calls zig functions
<bketelsen>
maybe a proxy on the JS side and a dispatcher on the zig side
<shritesh>
bketelsen: makes sense
<shritesh>
Also, how we separate js / browser is an open question. We need to support nodejs-isms too.
fengb_ has joined #zig
<fengb_>
I would like to port musl to wasm. Would I be biting off more than I can chew?
<keveman>
There is bar(), where a function marked inlined is called 2 times, and there is baz() where the same function is called 3 times..
<keveman>
all calls are inlined in bar(), but none of the calls are inlined in baz()
<keveman>
From the documentation page: "If the function cannot be inlined, it is a compile-time error.". I am wondering why I don't get a compiler error..
keveman has quit [Quit: Page closed]
<tgschultz>
keveman, I don't have experience reading llvm output but it looks like neither case is inlined in your gist. However, I can confirm on godbolt that all cases are inlined.
keveman has joined #zig
<keveman>
tgschultz, thanks. My bad, I was looking at the disassembly for my backend which is where I noticed that the first cast was inlined, the second was not
<keveman>
you are right, in the llvm IR, both cases are not inlined..
TheLemonMan has quit [Quit: "It's now safe to turn off your computer."]
<keveman>
This makes me wonder about the guarantees for `inline` functions.. It seems like it's only a compiler error if the function *cannot* be inlined for some reason..
<keveman>
If it indeed *can* be inlined, there is no compiler error, but it could still not be actually inlined, depending on some other criteria?
ltriant has joined #zig
<tgschultz>
I have no idea. Could be that the LLVM IR is a pre-inlined representation and the inlining happens later. I don't work on the compiler itself so I'm just guessing.
<forgot-password>
Hey guys, would somebody mind explaning why the setBit function (see https://godbolt.org/z/fx9W_c) generates as much assembly as it does?
<forgot-password>
I would expect the @intCast to only be relevant at compile time. The shifts, ors and ands are single instructions so it doesn't add up to me
<forgot-password>
Or is it related to runtime safety?
slugm_ has joined #zig
slugm has quit [Ping timeout: 244 seconds]
slugm_ has quit [Remote host closed the connection]
Jenz has quit [Ping timeout: 246 seconds]
<tgschultz>
@intCast asserts that the cast doesn't cause overflow
<tgschultz>
so it is a no-op in release-fast/small, but in debug/safe it checks
hio has quit [Quit: Connection closed for inactivity]
<forgot-password>
tgschultz: Got it, thank you!
fengb_ has joined #zig
halosghost has quit [Quit: WeeChat 2.4]
forgot-password has quit [Quit: leaving]
ltriant has joined #zig
ltriant has quit [Ping timeout: 244 seconds]
<emekankurumeh[m]>
did zig fmt ever have a feature for auto-converting line endings or did i just imagine that?
fengb_ has quit [Ping timeout: 256 seconds]
<hryx>
emekankurumeh[m]: line endings other than LF are illegal at the encoding level, so I think the file would fail to parse before it ever gets to zig fmt
<hryx>
in other words, non-LF line endings are invalid tokens and therefore can't be reformatted
<hryx>
(sorry, re-reading your question closer: not sure if that ability existed previously)
<shritesh>
I may have implemented that feature
<tgschultz>
I thought I saw that feature was implemented recently, but don't take my word for it. It's one of the use cases for zig-fmt
<hryx>
I certainly could be misremembering the conclusion of the original discussion
ltriant has joined #zig
Ichorio has quit [Ping timeout: 246 seconds]
fengb_ has joined #zig
<fengb_>
Getting this error when trying to process_headers: /deps/zig/libc/process_headers.zig:279:25: error: container 'builtin.Arch' has no member called 'nios2'
Sahnvour has quit [Read error: Connection reset by peer]