Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 02 23:04
    straight-shoota milestoned #12188
  • Jul 02 19:13
    Blacksmoke16 labeled #12189
  • Jul 02 19:13
    Blacksmoke16 labeled #12189
  • Jul 02 19:11
    asterite opened #12189
  • Jul 02 19:09
    asterite assigned #12187
  • Jul 02 16:53
    HertzDevil edited #12186
  • Jul 02 16:53
    HertzDevil edited #12186
  • Jul 02 15:24
    Blacksmoke16 labeled #12187
  • Jul 02 15:24
    Blacksmoke16 labeled #12187
  • Jul 02 15:19
    HertzDevil edited #12186
  • Jul 02 15:18
    HertzDevil edited #12186
  • Jul 02 15:16
    HertzDevil labeled #12188
  • Jul 02 15:16
    HertzDevil labeled #12188
  • Jul 02 15:16
    HertzDevil opened #12188
  • Jul 02 15:07
    cyangle labeled #12187
  • Jul 02 15:07
    cyangle opened #12187
  • Jul 02 13:58
    HertzDevil labeled #12186
  • Jul 02 13:58
    HertzDevil labeled #12186
  • Jul 02 13:58
    HertzDevil labeled #12186
  • Jul 02 13:58
    HertzDevil labeled #12186
didactic-drunk
@didactic-drunk
I guess that wasn't a shortened answer
ryanprior
@ryanprior:matrix.org
[m]
I'm having trouble casting a type to a more permissive type. For example, suppose I define my type as:
alias PermissiveType = Array(String | Int32) | String
s : PermissiveType = "hello world" #works
ss : PermissiveType = ["hello", "world"] # must be (Array(Int32 | String) | String), not Array(String)
It seems like since PermissiveType is strictly more permissive than Array(String) this cast should be possible - any possible value of that more restrictive type should satisfy the more permissive type.
How do I accomplish that?
Kirk Haines
@wyhaines

@ryanprior:matrix.org What you are running into is that while one can logically look at an Array(String) and see that an Array(String | Int32) can store everything in it, type specifications are very specific, and your type specification is for two things, either an Array(String | Int32), or String, and what you are trying to assign is an Array(String), which is not either of those things.

ss : PermissiveType = Array(String | Int32).new + ["hello", "world"]

That will create an array with a type signature that matches what PermissiveType allows.

Ali Naqvi
@naqvis
^ or provide the type of literal
ss : PermissiveType = ["hello", "world"] of String | Int32
if yo don't provide the type, compiler will infer that as Array(String)
Kirk Haines
@wyhaines
Thanks. My daughter interrupted me to move the van, and you finished for me. :)
Ali Naqvi
@naqvis
:P
Kirk Haines
@wyhaines
@ryanprior:matrix.org are you the current maintainer of crystal-readline? I have a private fork of it that I have been forced to maintain because the mainline lacks proper Crystal 1.0+ support. If I provide a PR, can we get the mainline project updated and a new release built?
ryanprior
@ryanprior:matrix.org
[m]
I'm not the maintainer but that would be useful for me too
Kirk Haines
@wyhaines
OK. I saw a commit from you on the main repo, so I was wondering.
Holden Omans
@kalinon
Anyone know how to build with -Dpreview_mt in the alpine-build docker image?
George Dietrich
@Blacksmoke16
try in the nightly image
3 replies
crystal-lang/distribution-scripts#63 was merged recently but not sure if it's actually in the nightly image atm or if there's another step that needs done to enable it
Holden Omans
@kalinon
oh nice ill try it out
didactic-drunk
@didactic-drunk
Is there a macro or easy way I can store the caller of .newfor reference later in finalize to track potential API misuse? I would prefer easy single line way to add this to any class
Kirk Haines
@wyhaines

@didactic-drunk that complete functionality doesn't exist so far as I am aware, but all of the building blocks exist. Maybe it can be my macro-hacking project of the week to build it.

Right now I am picturing something such as simple as include CallTrace, followed by an annotation on top of any method that one want's to build a call tracing stack for.

The actual call trace would be accessible at any time.

Jonathan Silverman
@mixflame
hello guys... this code pings out on Rizon (Ping Timeout) after it joins the #8chan channel... I asked in #Help on Rizon but I'll post the code here in case anyone wants to try to find the issue.... it has to do with the level of chatting... I suspect I need a "spawn" somewhere. https://gist.github.com/mixflame/e4bc13dd5d9a73af1524b2fe52c430a6
note that rizon is a custom network with special requirements that other networks don't possess.... like pinging on connect... might look wrong for other networks or just be fine... not sure about IRC internals as much as others might be
if you want to use it to build a bot, go ahead, it's based on the irc lib for crystal on github
be aware of the ping issue and if you find a solution let me know
Matthew Berry
@mattrberry
How do you properly case over a runtime type of an object? https://carc.in/#/r/bc3v
George Dietrich
@Blacksmoke16
Matthew Berry
@mattrberry
Ah
Thank you
I feel like mine should still work though
Or am I misunderstanding something?
(sorry for sending 4 messages when I could have sent 1 lol)
Also as a side note, I feel like we shouldn't need to include A as one of the branches of the case since it cannot have an instantiation at runtime
Quinton Miller
@HertzDevil
George Dietrich
@Blacksmoke16
Is nothing preventing you or someone else to extend it and break it
Quinton Miller
@HertzDevil
well you definitely cannot omit A.class for the original snippet because A is indeed an instantiation of A.class
Matthew Berry
@mattrberry
Ah, gotcha
If I wanted to check the runtime type of an object in my example there, but I defined === on A, how would I go about doing that? Or would I just have to use a conditional expression to check the class?
George Dietrich
@Blacksmoke16
sure you want === and not ==?
Matthew Berry
@mattrberry
I don't actually have a use-case for it
I'm just wondering
George Dietrich
@Blacksmoke16
=== should only be needed if you need custom case equality logic
it might just work tbh, like see the the when value is a type as the compiler expands it to is_a?
Matthew Berry
@mattrberry
Oh does the compiler special-case that?
George Dietrich
@Blacksmoke16
i think so yea
be easy enough to try
Matthew Berry
@mattrberry
Yeah seems like it does
Only other thing then would be that this should technically be able to compile I believe, since foo.is_a? cannot be an A, right? https://carc.in/#/r/bc45
Quinton Miller
@HertzDevil
that's what that rfc discusses
Matthew Berry
@mattrberry
Ah gotcha, thank you
George Dietrich
@Blacksmoke16
well technically foo.is_a? A would be true in either case
since its a parent to both
Ali Naqvi
@naqvis
true, case will end on the very first match, so for such scenario its better to move the parent or more general type to the end