ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Fund Crystal's development: | GH: | Docs: | Gitter:
notzmv has joined #crystal-lang
notzmv has quit [Ping timeout: 240 seconds]
<FromGitter> <skurhse> @deiv
<FromGitter> <skurhse> am i missing a part of your replication case
sorcus has quit [Quit: WeeChat 3.4]
<FromGitter> <Blacksmoke16> you should use `./bin/crystal`
notzmv has joined #crystal-lang
<FromGitter> <skurhse> okay so if I run `make spec` I also get a failure on bookworm
<FromGitter> <skurhse> `collect2: error: ld returned 1 exit status`
<FromGitter> <skurhse> `usr/bin/ld: cannot find P-ointer40H-ash58-515311c61a63528ca425ee8ac32c70d7.o: No such file or directory`
<FromGitter> <Blacksmoke16> is there anymore to the error
<FromGitter> <Blacksmoke16> output that is* might also be worth clearing cache `rm -rf ~/.cache/crystal`
sagax has joined #crystal-lang
_whitelogger has joined #crystal-lang
f1refly has quit [*.net *.split]
void09 has quit [*.net *.split]
lanodan has quit [*.net *.split]
markmarkmark has quit [*.net *.split]
avane has quit [*.net *.split]
repo[m] has quit [*.net *.split]
[R] has quit [*.net *.split]
kevinsjoberg has quit [*.net *.split]
jhass[m] has quit [*.net *.split]
xiamx has quit [*.net *.split]
spuun has quit [*.net *.split]
sagax has quit [*.net *.split]
SamantazFox has quit [*.net *.split]
Vexatos has quit [*.net *.split]
wolfshappen has quit [*.net *.split]
greenbigfrog has quit [*.net *.split]
dannyAAM has quit [*.net *.split]
adam12 has quit [*.net *.split]
raz has quit [*.net *.split]
riza has quit [*.net *.split]
kiwiroy has quit [*.net *.split]
pusewic|away_ has quit [*.net *.split]
peer has quit [*.net *.split]
Stephie has quit [*.net *.split]
antoszka-r has quit [*.net *.split]
jrayhawk has quit [*.net *.split]
dom96 has quit [*.net *.split]
Flipez has quit [*.net *.split]
mattt2 has quit [*.net *.split]
fifr[m] has quit [*.net *.split]
xybre has quit [*.net *.split]
HumanG33k has quit [*.net *.split]
ua_ has quit [*.net *.split]
Liothen has quit [*.net *.split]
pixel has quit [*.net *.split]
mookie has quit [*.net *.split]
repo has quit [*.net *.split]
mattt2 has joined #crystal-lang
sagax has joined #crystal-lang
greenbigfrog has joined #crystal-lang
dannyAAM has joined #crystal-lang
[R] has joined #crystal-lang
kevinsjoberg has joined #crystal-lang
spuun has joined #crystal-lang
kiwiroy has joined #crystal-lang
raz has joined #crystal-lang
peer has joined #crystal-lang
riza has joined #crystal-lang
pusewic|away_ has joined #crystal-lang
Stephie has joined #crystal-lang
pixel has joined #crystal-lang
ua_ has joined #crystal-lang
HumanG33k has joined #crystal-lang
Liothen has joined #crystal-lang
xybre has joined #crystal-lang
jrayhawk has joined #crystal-lang
repo[m] has joined #crystal-lang
antoszka-r has joined #crystal-lang
fifr[m] has joined #crystal-lang
dom96 has joined #crystal-lang
void09 has joined #crystal-lang
repo has joined #crystal-lang
wolfshappen has joined #crystal-lang
adam12 has joined #crystal-lang
mookie has joined #crystal-lang
Vexatos has joined #crystal-lang
jhass[m] has joined #crystal-lang
Flipez has joined #crystal-lang
xiamx has joined #crystal-lang
SamantazFox has joined #crystal-lang
avane has joined #crystal-lang
markmarkmark has joined #crystal-lang
lanodan has joined #crystal-lang
f1refly has joined #crystal-lang
Starfoxxes has quit [Max SendQ exceeded]
Starfoxxes has joined #crystal-lang
r0bby has quit [Ping timeout: 240 seconds]
r0bby has joined #crystal-lang
notzmv has quit [Ping timeout: 240 seconds]
notzmv has joined #crystal-lang
<FromGitter> <> little shard I created to help with files in static binaries
<FromGitter> <Blacksmoke16> just an fyi 🙈
<FromGitter> <> I know, But I wanted to use the standard lib FS
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <> this just restores files to their original location
<FromGitter> <Blacksmoke16> ahh nice
<FromGitter> <Blacksmoke16> that makes snse
<FromGitter> <> which means they dont have to stay in memory either, and can be garbage collected :-)
<FromGitter> <> I think baked, they stay in memory for the life of the application
<FromGitter> <Blacksmoke16> dunno, never used it
<FromGitter> <Blacksmoke16> but pretty cool. the power of macros :P
<FromGitter> <> ya, I love that you can call out to another full crystal program to generate code
<FromGitter> <> its like a dream within a dream
<FromGitter> <Blacksmoke16> part of me wonders if interpreter land can improve that at all. Like can i pipe a heredoc into it and get data back? 🤔
<FromGitter> <> I tried to do that, got some weird results though
<FromGitter> <> but I probably could have returned the heredoc in the body itself
<FromGitter> <skurhse> What's the best way to debug `make spec`
<FromGitter> <Blacksmoke16> whats the error?
<FromGitter> <skurhse> errors
<FromGitter> <Blacksmoke16> like failing tests, or it fails to run, or some tests have errors
<FromGitter> <Blacksmoke16> its also possible to run single test files, most likely dont need to run the *entire* spec suite
<FromGitter> <skurhse> is it possible to upload files
<FromGitter> <Blacksmoke16> to gitter?
<FromGitter> <skurhse> ye
<FromGitter> <skurhse> i have the run log
<FromGitter> <Blacksmoke16> dont think so, id use pastebin or something for that
<FromGitter> <skurhse> `make spec 2>&1 | clip.exe`
<FromGitter> <skurhse> god pastebin is ad hell
<FromGitter> <Blacksmoke16> oh, are you on windows?
<FromGitter> <skurhse>
<FromGitter> <skurhse> ```code paste, see link``` []
<FromGitter> <skurhse> i imagine I am missing a package dependency
<FromGitter> <Blacksmoke16> ah wsl, entirely possibly its just a wsl issue with bookworm
<FromGitter> <skurhse> wsl2 is a virtual machine
<FromGitter> <skurhse> so this should work exactly like it does on bare metal
<FromGitter> <skurhse> this confuses everyone because wsl1 was a compatibility layer like cygwin
<FromGitter> <Blacksmoke16> looks fairly up to date
oprypin has quit [Ping timeout: 268 seconds]
<FromGitter> <skurhse> fwiw i can succeed `make`
oprypin has joined #crystal-lang
<FromGitter> <skurhse> just `make spec` failing like it is for @deiv but for a different reason
<FromGitter> <Blacksmoke16> prob missing one of the `lib*` deps?
<FromGitter> <skurhse> that or this link stmt `ln -sf /usr/bin/ld.lld-8 /usr/bin/ld.lld`
<FromGitter> <Blacksmoke16> could also try clearing crystal cache
<FromGitter> <Blacksmoke16> `rm -rf ~/.cache/crystal`
<FromGitter> <Blacksmoke16> looks similar to
<FromGitter> <skurhse> ```code paste, see link``` []
<FromGitter> <Blacksmoke16> llvm-8 is quite old at this point
<FromGitter> <skurhse> it does look like that issue
<FromGitter> <skurhse> it's definitely a linkage editor issue
<FromGitter> <skurhse> `collect2: error: ld returned 1 exit status`
<FromGitter> <skurhse> i will do some research
Guest62 has joined #crystal-lang
Guest62 has quit [Quit: Client closed]
<FromGitter> <> hi, why is this code compliing? ⏎ `@debug` is declared as a `Bool`, but I am assigning it the value from a method that returns a `Bool?`
<FromGitter> <Blacksmoke16> compiler seems to figure out it always returns a bool
<FromGitter> <Blacksmoke16>
<FromGitter> <> hmm I am not sure I want the compiler to infer that ^^
<FromGitter> <> but it avoid me to duplicate the method in this case
<FromGitter> <skurhse> the return value can be null
<FromGitter> <skurhse> if `value` is null
<FromGitter> <> yep, but if `value` is of type `Bool`, the return type can only `Bool` (either the result of `==`, either `value` itself)
<FromGitter> <> so the compiler is right, but it feels strange
<FromGitter> <Blacksmoke16> llvm optimizations ftw :P
<FromGitter> <skurhse> one thing about crystal
<FromGitter> <skurhse> is that it only adds the method signatures it needs per static analysis
<FromGitter> <skurhse> so it's good to write good test cases
<FromGitter> <skurhse> for instance with the right test case your code would return ⏎ `Error: instance variable '@debug' of Test must be Bool, not (Bool | Nil)`
<FromGitter> <Blacksmoke16> do you have the code that produces it? because he has a method call for each case and it works fine
<FromGitter> <> The thing is type restrictions are not strict in Crystal. I must admit I've never totally liked it, but I understand the point.
<FromGitter> <Blacksmoke16> actually, interestingly enough if you do `read_bool(@debug, nil, "DEBUG")` still seems to know its always a `Bool`
<FromGitter> <skurhse>
<FromGitter> <Blacksmoke16> oh sorry, nvm. `nil` is being passed as a default, return type would still correctly be bool
<FromGitter> <Blacksmoke16> well thats a compiler bug right there
<FromGitter> <skurhse> if you're not invoking a certain type case then the compiler does not care if other permutations violate it
<FromGitter> <skurhse> at least I thought that how it worked
<FromGitter> <skurhse> I agree it is confusing
<FromGitter> <Blacksmoke16>
<FromGitter> <Blacksmoke16> is because `read_bool` returns `Bool?` when your local var is typed as `Bool`, thats prob a bug. might be an issue for it somewhere
<FromGitter> <> IIRC the type annotations are checked near the end of the compilation process, after code generation?
<raz> not sure i see the bug there. compiler would still complain if your method could actually return nil.
<FromGitter> <Blacksmoke16> think that case just needs a better error. e.g. if you did `record Foo, test : Bool = (false || nil)` you'd get a proper trace and `Error: instance variable '@test' of Foo must be Bool, not (Bool | Nil)`
<FromGitter> <skurhse> you definitely proved undefined behavior
<FromGitter> <Blacksmoke16> versus a more generic `Error: type must be Bool, not (Bool | Nil)`
<FromGitter> <skurhse> `(false || nil)` is always `nil`
<FromGitter> <skurhse> so if value permutations are discrete
<FromGitter> <skurhse> `type must be Nil`
<FromGitter> <Blacksmoke16> the runtime value of it is always `nil`, but its type is `Bool?`
<FromGitter> <Blacksmoke16> e.g. try `pp typeof((false || nil))` versus `pp (false || nil).class`
<FromGitter> <Blacksmoke16> the former is the compile time type, while the latter is runtime type
<FromGitter> <skurhse> yes it's a bug
<FromGitter> <skurhse> compare to `a : Nil = nil unless false` which works as expected
<FromGitter> <skurhse> wait I'm dumb
<FromGitter> <skurhse> ```a : Nil = if false ⏎ false ⏎ else ⏎ nil ⏎ end``` []
<FromGitter> <skurhse> same behavior
<FromGitter> <skurhse> why this contradicts 's case is still strange tho
<FromGitter> <Blacksmoke16> and to be clear, imo, the bug here is the error message isn't super clear what the problem is, not that it shouldnt fail
<FromGitter> <skurhse> why does it not fail in 's case tho
<FromGitter> <skurhse> it seems it should but it does not
<FromGitter> <Blacksmoke16> it would if `value` and `default` are both `nil` for `@debug`
<raz> yup. in his pastie `@debug : Bool` is never violated
<FromGitter> <skurhse> ```code paste, see link``` []
<FromGitter> <skurhse> both cases should have consistent behavior
<FromGitter> <skurhse> but this one does not fail
<raz> it should fail if you call `test(nil)`
<FromGitter> <Blacksmoke16>
<FromGitter> <skurhse> it appears to make assumptions about runtime types only where they're parameters
<FromGitter> <Blacksmoke16> it prob optimizes types away when they're hard coded
<FromGitter> <skurhse> it does but why not the same behavior for this
<FromGitter> <skurhse>
<FromGitter> <skurhse> they can be inferred as well
<raz> compiler apparently not smart enough to realize that it always evaluates to Nil
<FromGitter> <Blacksmoke16> :shrug: if i had to guess its all based on compile time type of the value, which in the case of `(false || nil)` is `Bool?` but passing `true` to `test` results in `pp typeof(x) # => Bool`
<FromGitter> <Blacksmoke16> ill defer to someone else if thats true or not, but afaik that seems to be whats going on
<FromGitter> <Blacksmoke16>
<FromGitter> <Blacksmoke16> like this introduces a union due to the runtime nature, which then fails the restriction since the type of `x` is now the union and not reduced to `Bool`
<FromGitter> <skurhse> ```code paste, see link``` []
<FromGitter> <skurhse>
<FromGitter> <Blacksmoke16> ```pp typeof(nil || true) # => Bool ⏎ pp typeof(false || nil) # => Bool | Nil ⏎ ``` []
<FromGitter> <Blacksmoke16> not saying this is how its expected to work, but it is how it does amt
<FromGitter> <jfontan> I am trying to make a fixed size array of type T. I am able to create it with `StaticArray(T, 10)` but I want the size to be specified by a variable. So it fails. I believe it is a macro and needs a number there. I'm also not able to create it with `T[@capacity]`. Do you know how it can be done?
<FromGitter> <Blacksmoke16> er what the reason it works like that is* i should say
<FromGitter> <Blacksmoke16> idt you can, static array sizes have to be known at a compile time
<FromGitter> <Blacksmoke16> because, you know, they're static
<FromGitter> <Blacksmoke16> could use a const or env value maybe?
<FromGitter> <jfontan> I may try using a normal array and pushing to it then
<FromGitter> <Blacksmoke16> you can use the expected size when creating the array to avoid reallocations
<FromGitter> <jfontan> gotcha
<FromGitter> <Blacksmoke16> i.e. allocate once for `@capacity` size
<FromGitter> <Blacksmoke16> @skurhse could maybe make a forum thread about why those two cases are different id you want
notzmv has quit [Ping timeout: 240 seconds]
<FromGitter> <skurhse> +1
<FromGitter> <skurhse> i'm going to do some rca
<FromGitter> <skurhse> trying to get more acquainted with compiler theory