jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.5.8 | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/manastech/crystal - Docs: http://crystal-lang.org/docs/ - API: http://crystal-lang.org/api/ - Logs: http://irclog.whitequark.org/crystal-lang
sferik has joined #crystal-lang
zamith has quit [Quit: Be back later ...]
travis-ci has joined #crystal-lang
<travis-ci> manastech/crystal#1834 (master - 9787fef : Ary Borenszweig): The build is still failing.
travis-ci has left #crystal-lang [#crystal-lang]
travis-ci has joined #crystal-lang
<travis-ci> manastech/crystal#1835 (master - a23644f : Ary Borenszweig): The build is still failing.
travis-ci has left #crystal-lang [#crystal-lang]
asterite has joined #crystal-lang
<jhass> asterite: when does "can't infer block type" happen?
<asterite> when it shouldn't :)
<asterite> It happens when the compiler needs the type of a block to use as a generic type
<asterite> >> def foo; foo; end; Array.new(4) { foo }
<CeBot> asterite: Error in line 3: can't infer block type
<asterite> >> class Foo; getter name; def initialize(@name); end; end; ([] of Foo).map &.name
<CeBot> asterite: in /usr/lib/crystal/array.cr:399: can't infer block type
<asterite> But I think in both cases it should work, it's just some current limitation
<asterite> Where are you getting it?
<asterite> In the first case the compiler didn't finished determining the type of 'foo', so it can't know the type of the Array
<jhass> any chance of making that message a bit more explanatory nonetheless? Like "Can't use XXX as block type because it's generic" or whatever?
<jhass> nothing I can manage to reduce enough :/
<asterite> Well, it's hard to explain why the compiler can't infer it. I'd like to remove that message forever and make the compiler smarter
<jhass> thing is I'm a bit puzzled as to why it happens
<asterite> Maybe if I let the type of the block be NoReturn in that case it might work. I'll try it soon :)
<asterite> Mmm...
<asterite> In what line you get it?
<jhass> it's happening essentially after doing something like .scan(pattern).map(&.[1]).map {|x| "#{x}" }.join(delim)
<jhass> but of course not if I reduce it to that
<jhass> http://paste.mrzyx.de/pd7wzgg3h actual error, of course lacking quite some context
<asterite> I like the path of the source code, though :)
<asterite> Mmm... can the compiler know the type of all of what's used there until that point?
<asterite> Mmm... do you capture a block or have a function pointer somewhere?
<jhass> kinda, maybe I should paste the full trace
<asterite> Please :)
<asterite> This is *the* error message that should be gone before 1.0
naps62 has quit [Ping timeout: 265 seconds]
shama has quit [Remote host closed the connection]
<asterite> Did you instantiate any plugin before that line?
<jhass> sure
<jhass> it's like the 9th plugin I write
<jhass> and the second most simple one
<jhass> not sure if I actually had a map before though, let me check
<asterite> As a workaround, when the compiler can't infer the type of a block you can tell it with `as`
<asterite> So `issues.map {|issue| "https://github.com/#{@projects[msg.channel.name]}/issues/#{issue[1]}" as String }` should work
<asterite> I think
<jhass> mmh, yeah, there's another one with a map that's working
<jhass> yup, looks like it
<jhass> "foo" as String seems weird though :P
<jhass> so block type == block return type?
<jhass> I think making that clear would help a bit already :)
<asterite> Yes
<asterite> Well, it's an interpolation and some part of it is untyped, so the whole expression gets untyped
<asterite> I promise I'll fix this... somehow. It happened to me many times and I used the "as" workaround, but once it happens to somebody else it's time to fix it :)
<asterite> Did the "as" thing work?
<jhass> yes
<asterite> On the other hand, if we explain that when the compiler tells you "can't infer block return type" you need to help it with an "as" cast, it's not that bad, really
<asterite> (but I'll fix it)
<asterite> Compared to other languages, the amount of explicit types you need to write is very low, so once in a while helping the compiler will have to happen, I guess
<jhass> yes, I think that's still a good thing to do as an interim improvement though
<asterite> What do you think?
<jhass> so, improve the message and then when you (or somebody else) happens to find a solution, the better
<jhass> I'd say
<asterite> Yes, I was going to do that
<asterite> I can't come up with a nice message, though
<asterite> "can't infer block type, ...?"
<jhass> "try casting the return value with `as`" ?
<jhass> looks like something segfaults when that code is called now :/
<jhass> oh, I made a stack overflow
<jhass> ah, so unterminated recursive call, called from within that expression
<jhass> which is probably why ther inference failed in the first place
<jhass> yap
<asterite> :)
<asterite> I was thinking of referencing that wiki page in the error message, because it's the most hard to understand message of all we have
<asterite> Do you think it's good, or not very good to have a link in an error message?
<jhass> as long as we have no offline docs anyway... ;)
<jhass> I'd say it's fine
<asterite> BTW, where was the recursion?
<jhass> msg.channel
<jhass> channel.not_nil! instead of channel?.not_nil!, silly mistake
<asterite> So CeBot has many plugins already?
<jhass> I'm porting the ones I have for my Ruby bot
<jhass> so I that I can eventually replace it
<asterite> Cool :)
<jhass> and that also should help stubbing out the basic functionality for the underlying libs
<asterite> Did you manage to use json_mapping?
<jhass> yes
<asterite> How are you doing the irc protocol?
<asterite> Just very curious :)
<jhass> first parser was based on some educated limited splits
<jhass> that required 5-6 runs through each message though, so I played around and have tiny tiny state machine now that requires only one run
<asterite> Nice :)
<asterite> I had an idea for some time, but I don't know if it's worth adding to the language. It's just a tiny syntax sugar
<asterite> had -> have (but I have it for some time)
<asterite> In Crystal you need to override to_s(io) instead of to_s, for performance
<jhass> so .each_char |char| and then StringIOs for the components, foo << char
<asterite> so you can't use interpolation there (or can, but it defeats the purpose)
<jhass> ^ is that actually a fast way?
<asterite> so you end up doing io << "something " << special << " and more"
<asterite> I think it's fast, yes
<asterite> But I was thinking maybe we can have "something #{special} and more"(io)
<asterite> That would write the interpolation to the given IO
travis-ci has joined #crystal-lang
<travis-ci> manastech/crystal#1836 (master - 1a75be2 : Ary Borenszweig): The build is still failing.
travis-ci has left #crystal-lang [#crystal-lang]
<jhass> mmh
<asterite> Too hacky?
<jhass> I'm not sure I like the syntax tbh. Let's toy around a bit. io << "foo <<special>> bar"
<jhass> which would rewrite to io << "foo " << (special).to_s << " bar"
<jhass> mmh
<asterite> there wouldn't be a need for the to_s
<jhass> not sure
<asterite> Yes, me neither (I'm not sure about the feature as a whole)
<asterite> but maybe it's annoying to do io << ... << (maybe not)
<jhass> I think it's a matter of getting used to it
shama has joined #crystal-lang
<jhass> it would be backwards compatible addition, maybe let's revisit when there are more people (=more ideas) around Crystal ;)
<asterite> Good :)
<asterite> Why your other bot is called DeBot?
<jhass> I originally wrote it for #diaspora-de ;)
shama has quit [Read error: Connection reset by peer]
shama has joined #crystal-lang
<asterite> I think an irc bot is a good small/medium program to learn a new language. I'll try to learn Rust and Nim with that idea
<asterite> I wanted to try those languages but didn't know what program to write
<jhass> dunno, IRC is actually a messy protocol
<jhass> almost as bad as telnet
<jhass> if not worse, since all IRCds do things slightly different
bcardiff has joined #crystal-lang
<jhass> but if you need no authentication and not much user/channel management, you can get up quite fast, yes
<jhass> it seems simple as first, but it's too loosely defined in the details
<jhass> which is because it was a guys idea in the early 80s or late 70s iirc which only in the middle or late 90s got an RFC
<jhass> which just tried to write down what the most popular IRCd did at that time
bcardiff has quit [Client Quit]
<asterite> :-P
shama has quit [Ping timeout: 245 seconds]
asterite has quit [Quit: Page closed]
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bcardiff has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
r20 has joined #crystal-lang
r20 has quit [Client Quit]
canhtak has joined #crystal-lang
canhtak has quit [Quit: canhtak]
canhtak has joined #crystal-lang
Excureo has quit [Quit: No Ping reply in 180 seconds.]
Excureo has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
zamith has joined #crystal-lang
canhtak has quit [Quit: canhtak]
leafybasil has joined #crystal-lang
canhtak has joined #crystal-lang
bcardiff has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
bcardiff has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
sferik has joined #crystal-lang
sferik has quit [Client Quit]
sferik has joined #crystal-lang
bcardiff has joined #crystal-lang
bcardiff has quit [Quit: Leaving.]
asterite has joined #crystal-lang
<jhass> asterite: any hints for "can't take address of fdset[0]"?
<jhass> fdset is a tuple
<jhass> bah, nvm
<asterite> Yes, for now you can only take an address of a variable or instance variable
<jhass> fdset wasn't defined, fdsets is
<jhass> ah, mh
<asterite> >> “foo bar”.split(/ /)
<CeBot> asterite: Syntax error in eval:3: unterminated call
<asterite> :-P
<asterite> >> require "compiler/crystal/version"; puts Crystal.version_string
<CeBot> asterite: in /usr/lib/crystal/compiler/crystal/config.cr:4: error executing command: (git describe --tags --long 2>/dev/null), got exit status 128
<jhass> mmh
<asterite> But that’s expected, I guess
<jhass> yes and no, gotta check why it failed
<jhass> mmh, it's not a git checkout
<jhass> so that fails with all packaged crystals
<jhass> where does crystal --version get it from again?
<asterite> It invokes Crystal.version_string
<asterite> And the version is VERSION = {{ env("CRYSTAL_CONFIG_VERSION") || `(git describe --tags --long 2>/dev/null)`.stringify.chomp }}
<asterite> But nevermind, in the compiled compiler that version is already there in the binary, but doing that using that compiler will fail
<jhass> so, something like Crystal::VERSION should work no?
<jhass> mmh, no
<jhass> it would be kinda neat though
<jhass> to be able to get the version of the compiler in a program that's being compiled
<asterite> It’s strange that the version is embedded in the compiler’s binary but I can’t think of a way to get it
<asterite> Yes, exactly
<asterite> Well, we would need a compile-time variable, I think
<jhass> I can imagine that to be useful for things beyond the version
<asterite> For example?
<jhass> compile date for example, maybe the compiled in CRYSTAL_PATH
<jhass> especially the later actually
<jhass> in case I want to reinvoke the compiler but with certain elements added or removed
<asterite> D for example has special tokens for that, like we have __FILE__: http://dlang.org/lex.html#specialtokens
<jhass> mmh, I'd all let them start with something like CrystalConfig:: then
<jhass> to fake regular constants
<asterite> It’s true, that module could be defined by the compiler and those constants be defined by it, too
<asterite> Similar to how ARGV_UNSAFE is defined by the compiler
<asterite> But… later :) When we really see the need for this, we’ll add it
asterite has quit [Quit: asterite]
asterite has joined #crystal-lang
asterite has quit [Client Quit]
canhtak has quit [Quit: canhtak]
asterite has joined #crystal-lang
asterite has quit [Client Quit]
bcardiff has joined #crystal-lang
CeBot has quit [Quit: Crystal]
CeBot has joined #crystal-lang
asterite has joined #crystal-lang
CeBot has quit [Quit: Crystal]
CeBot has joined #crystal-lang
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
asterite has quit [Quit: asterite]
sferik has joined #crystal-lang
zamith has quit [Quit: Be back later ...]
canhtak has joined #crystal-lang
canhtak has quit [Quit: canhtak]
asterite has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
travis-ci has joined #crystal-lang
<travis-ci> manastech/crystal#1837 (master - d378055 : Ary Borenszweig): The build was fixed.
travis-ci has left #crystal-lang [#crystal-lang]
sferik_ has joined #crystal-lang
sferik has quit [Ping timeout: 264 seconds]
shama has joined #crystal-lang
random_something has joined #crystal-lang
random_something has quit [Remote host closed the connection]
random_something has joined #crystal-lang
random_something has quit [Remote host closed the connection]
r20 has joined #crystal-lang
<jhass> >> / /
<CeBot> jhass: / /
<asterite> :-D
<jhass> \o/
<asterite> Can the bot read from the internet?
<jhass> sure
<jhass> didn't enable any plugins here that do so though
<jhass> or maybe
<jhass> !up google.com
<CeBot> It's just you. http://google.com is up
<jhass> yup, that does read from the internet :D
<asterite> >> require "http/client"; puts HTTP::Client.get("http://www.google.com").body.lines.first
<CeBot> asterite: Program terminated abnormally with error code: 31
<jhass> ah yeah, the sandbox might not :P
<jhass> I'm not yet sure if I want to let it to
<jhass> I should improve the message
<asterite> No problem, I was just toying with the bot :)
<jhass> sure, feel free to break it
<jhass> it needs that, it runs untrusted code ;)
<asterite> >> `rm -rf /`
<CeBot> asterite: ""
<asterite> ;)
<asterite> >> `sudo rm -rf /`
<CeBot> asterite: ""
<jhass> /bin/sh: line 1: sudo: command not found\n
<jhass> ;)
zamith has joined #crystal-lang
<zamith> asterite: Do you have anything you want me to add to my slides?
<zamith> Any new stuff coming?
sferik_ has quit [Quit: Textual IRC Client: www.textualapp.com]
<asterite> zamith: I don’t think so, I’m mostly fixing bugs and stabilizing things latelty (and reviewing/accepting pull requests, actually)
<asterite> You’ll reuse your slides?
<zamith> most of them, yeah
<jhass> >> %w[a b c]
<CeBot> jhass: Syntax error in eval:3: unexpected token: %
<jhass> :(
<zamith> not a lot has change in a week
<zamith> :)
<asterite> jhass: parenthesis for now, but you can create an issue for that :)
<jhass> ah
<zamith> I was going to say I saw support for %w when going through the parser
<asterite> I guess (, [ and { will be enough, right? I think ruby supports more delimiters but I never saw anyone using them
<zamith> guess that's it
<jhass> yeah was going to write that into the issue
<jhass> ruby supports any single char as delimiter
<jhass> it just special cases ([{ to end with }])
<jhass> mmh, < maybe
<zamith> any non alphanum char
<asterite> I don’t think we’ll copy that :)
<zamith> or at least it won't take alphanum
<asterite> I think (, { and [ are enough
<zamith> I guess so
<zamith> the idea is so that it works even if you need any of those chars in the strings
<zamith> but I've never used anything other than those
<asterite> Yeah, I think it’s hard to find a case where you need (, { and [ inside a string
<asterite> zamith: if you’d like to hack the compiler, adding support for %w[ and others can be a small task. But you’ll need to store the delimiter so then you can know when it ends (it’s already implemented for string literals). I’m just suggesting this because you asked about that other lexer-related issue :)
<zamith> sure, I can give it a go
<zamith> Do you mean use a Token::DelimiterState?
<zamith> I think that's the name
<asterite> Yes, that one. It’s currently use when lexing a string, but you can reuse it in this case (the cases don’t overlap)
<asterite> There’s also lexer_string_array_spec.cr to understand how it’s used by the parser
<zamith> it's also used in regexes, right?
<zamith> that's where I saw it, I believe
<zamith> I'l give it a look, thanks
<asterite> Yes
<asterite> Only if you want to. I can do it too, but the comment on the issue gave me the impression that you wanted to touch the compiler (but I might be wrong!)
<zamith> Sure
sferik has joined #crystal-lang
<zamith> I'm not sure how much I'll be able to accomplish, but it won't hurt to give it a try
<zamith> :)
<asterite> :)
<asterite> zamith: where will you give the talk, another ruby meetup?
<zamith> yeah
<zamith> it's like 10/12 people at a time
<zamith> but at least we'll be talking about it
<zamith> they invited me, because they were interested in the language
<zamith> :)
<asterite> That’s really nice to hear! :)
CeBot has quit [Quit: Crystal]
CeBot has joined #crystal-lang
<jhass> >> `rm -rf /`
<CeBot> jhass: Sorry, I can't let you do that.
<jhass> :(
<jhass> CeBot: why not?
<asterite> :-D
<asterite> How do you know when to say that?
<jhass> when that bad system call message appears in the output ;)
<jhass> >> require "http/client"; puts HTTP::Client.get("http://www.google.com").body.lines.first
<CeBot> jhass: Sorry, I can't let you do that.
<asterite> Cool
<jhass> >> `sudo rm -rf /`
<CeBot> jhass: /bin/sh: line 1: sudo: command not found
<jhass> your turn to break it again :P
<asterite> >> def foo; foo; end; foo
<CeBot> asterite: Program terminated abnormally with error code: 135
<jhass> 135 is stack overflow
<jhass> I'll leave printing a nice message there to crystal :P
<asterite> Hehehe, I imagined you would do so :)
<r20> jhass, is the bot running in a jail or under selinux/apparmor
<jhass> jail
<r20> cool
<jhass> playpen to be specific
sferik_ has joined #crystal-lang
<r20> oh it hits their HTTP API?
<asterite> We wanted to use playpen or docker to do a website for running crystal code and executing it, maybe also seeing the llvm output
<jhass> nah, local install
<jhass> that thing
<r20> nice
<jhass> what website? never seen it
sferik__ has joined #crystal-lang
<jhass> oO three sferik's
sferik_ has quit [Read error: Connection reset by peer]
<r20> that'd be cool, i dont know how tryruby.org works anymore it seems to use jruby sandboxing
<jhass> at times I had the feeling regexp and premade answers :/
<r20> doomed to fail :)
sferik has quit [Ping timeout: 264 seconds]
<jhass> >> "foo".gsub! 'a', 'b'
<CeBot> jhass: Error in line 3: undefined method 'gsub!' for String (did you mean 'gsub'?)
<jhass> just missing or is there a reason?
<r20> arent strings immutable
<jhass> maybe, I didn't notice but I guess you're right
<r20> im not sure
<asterite> yes, strings are immutable
<zamith> asterite: how can I run the tests for a specific file?
<jhass> just run the spec file
<asterite> bin/crystal your_spec_file.cr
<asterite> You can also do bin/crystal spec your_spec_file.cr:12
<asterite> for a specific line number (must match the “it” line)
<zamith> it's throwing an error
<zamith> :s
<asterite> what error?
canhtak has joined #crystal-lang
<asterite> Oh, you are running of the compiler specs?
<asterite> You need to install llvm 3.5
<zamith> oh ok
<asterite> I definitely need to add a page in the docs explaining how to contribute :)
<jhass> CONTRIBUTING.md in the repo is a convention, I think github even hints it somewhere while forking or doing a PR ;)
<zamith> Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
<zamith> this is what I have
<asterite> jhass: good, I’ll do that
<asterite> Do you have llvm-config in the PATH?
<zamith> nop
<zamith> where is that?
<asterite> Also, when running compiler specs be sure to use bin/crystal instead of crystal, because “src” is not in the CRYSTAL_PATH so it will find the “src” of your installed crystal
<asterite> It comes with llvm binaries
<asterite> Who gave you the string “Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)” ?
<zamith> clang --version
<asterite> Oh, maybe you have clang but not llvm
<zamith> I can try brew --prefix llvm
<asterite> Sure
<zamith> and add that to the path
<asterite> Oh maybe llvm is not linked by default, I did `brew link llvm --force`
sferik has joined #crystal-lang
<zamith> I don't think so
<zamith> that works
<zamith> thanks
<asterite> Cool!
<zamith> the linking I mean
sferik__ has quit [Ping timeout: 264 seconds]
<zamith> asterite: so, I have to store the opening char somewhere. Is an instance variable good enough?
<zamith> *a
<asterite> You can store it in Token’s @delimiter_state
<zamith> ok
<asterite> You have “kind, nest, :end, open_count” as fields, you can do `Token::DelimiterState.new(:array, ‘(‘, ‘)’, 0)` for example
<asterite> Oh, about #334, we could add the expect syntax but then there will be two ways to do the same thing. For now there’s no real pressure to change this, I think
asterite_ has joined #crystal-lang
asterite has quit [Ping timeout: 255 seconds]
asterite_ is now known as asterite
_whitelogger__ has joined #crystal-lang
<zamith> I personally prefer the expect syntax, because it is very is to see what is the object and what is the expectation
<zamith> but it's ok either way
_whitelogger_ has quit [*.net *.split]
<asterite> Yes, I just did a couple of changes to see how it looks, and it is indeed a bit more readable
drizz has quit [Quit: d]
<asterite> but it takes a bit longer to write (pressing shift twice for the parenthesis), plus you have to remember to start with “expect(“, so I’m not sure which one I like most
<zamith> asterite: I'm trying to move the parsing of string array to the regular delimiters
<zamith> so, DELIMITER_START and DELIMITER_END, and use the kind to tell them apart
<asterite> Good :)
<zamith> it all works well up to parse_delimiter, where I get the pieces correctly, but I want to create an ArrayLiteral, and it breaks
<zamith> :s
<asterite> how it breaks?
<zamith> case delimiter_state.kind
<zamith> when :command
<zamith> result = Call.new(nil, "`", result)
<zamith> when :regex
<zamith> result = RegexLiteral.new(result, modifiers)
<zamith> when :string_array
<zamith> ArrayLiteral.new(pieces)
<zamith> end
<zamith> this, /Users/zamith/Projects/personal/crystal/crystal/src/pointer.cr:21
<zamith> (self + offset).value
<zamith> and in /Users/zamith/Projects/personal/crystal/crystal/src/compiler/crystal/syntax/to_s.cr:91: undefined method 'accept' for String
<zamith> exp.accept self
<zamith> this
<asterite> Oh, the method to parse that is parse_string_or_symbol_array
drizz has joined #crystal-lang
<zamith> I know
<zamith> I'm trying to get rid of that
<asterite> Oh, so you want to unify both methods?
<zamith> because it has nothing special really, apart from the fact that the pieces are put together into an array
<zamith> yes
<asterite> Ah, it breaks because pieces is `pieces = [] of ASTNode | String`, so you are passing a String to an ArrayLiteral.new
<zamith> pieces is Array((Crystal::ASTNode+ | String))
<zamith> at least that's what .class says
<asterite> Yes, and if you do `ArrayLiteral.new(pieces)` it will fail because it expects an Array(ASTNode) (not of String)
<zamith> I tried pieces of ASTNode
<zamith> but it doesn't work
<zamith> :S
<zamith> is there a way to do this?
<asterite> with an `as` or how?
<zamith> sorry?
<asterite> “I tried pieces of ASTNode” -> what do you mean?
<zamith> pieces as Array(ASTNode)?
<zamith> I tried with of
<zamith> what's the difference?
<asterite> `of` is just for the array/hash literal literal syntax
<zamith> as is type casting?
<asterite> but you can’t use `as` for what you want
<zamith> oh ok
<asterite> yes, but the cast should fail if any of the elements in the array is indeed a String
<zamith> yeah
<zamith> it does
<zamith> :)
<zamith> it has to be a StringLiteral?
<asterite> I mean, if we decide to allow this case, at runtime this must be checked
<asterite> but it’s expensive
<zamith> I can map over it and transform into string literals, right?
<zamith> like it does for interpolations
<asterite> Yes, that might work
<asterite> The error you got when you did `ArrayLiteral.new(pieces)` was probably long and hard to understand, right?
<zamith> yup
<zamith> but I guess it's internal
<zamith> so, not a big issue
<asterite> No, it’s not internal :(
<asterite> but with the global type inference it gets harder to correctly report errors
<asterite> What I usually do is go line by line (in the error trace) and see where is a method call with a type I know shouldn’t be there
<asterite> One of the lines is: instantiating 'Crystal::ArrayLiteral:Class#new((Array((Crystal::ASTNode+ | String)) | Array(Crystal::ASTNode+)))'
<asterite> so there it says that ArrayLiteral.new is invoked with a union of things that don’t make sense (for the programmer)
<zamith> hum...
<asterite> But if anyone thinks of a better way to report these errors, you are very welcome :)
<zamith> so this is the error for any bad invocation?
<asterite> Yes. Well, it depends on where the error happened
r20 has quit [Quit: Leaving]
<asterite> The last line in the error is “undefined method 'accept' for String” in “exp.accept self”, underlining “exp”
<asterite> So the compiler deduced exp can potentially be a String
<asterite> and that exp came from the ArrayLiteral @exps variable
<asterite> Kind of hard to explain… in Ruby you would get the same error, you would get “undefined method accept for String” and then you’ll have to figure how a String came into that variable (or a nil, which is the most common case)
<asterite> only here you get a backtrace of the origin of that type… I don’t know if there’s a better way to do it
<zamith> it looks like a hard problem
<zamith> but a lot of output sometimes is bad, it looks scary
<zamith> :P
<zamith> the delimiter being tokenized as START STRING END
<zamith> even though the STRING has spaces
<zamith> the spaces should be a separator
<zamith> is that because of how regular delimited things work?
<asterite> The spaces are only separators when you do %w(foo bar)
<asterite> but in “foo bar” they are just part of the STRING
<zamith> yeah...
<asterite> I’m not sure it’ll be easy to unify the two methods. One invokes next_string_token, the other one invokes next_string_array_token
<asterite> Or: I would try to make it work first, and then refactor (if possible)
<zamith> ok
<asterite> Explaining you the error messages I think I can improve them by pointing you to the main line that caused the error to propagate. I’ll try :)
<zamith> i like how the stack trace is inverted
<zamith> and i only have to look to the line right above the prompt
<asterite> There are actually two traces: one for where the type leading to the error originated, and one for the instantiation backtrace. But sometimes the line right above the prompt gives you a hint but you have to look at the whole thing to understand it
<zamith> in /Users/zamith/Projects/personal/crystal/crystal/src/compiler/crystal/codegen/target_machine.cr:11: undefined method 'from_triple' for LLVM::Target:Class
<zamith> target = LLVM::Target.from_triple(target_triple)
<zamith> asterite: is this an issue with the llvm?
<asterite> We added that a few days ago, you might need to git pull
<asterite> Oh
<asterite> And remember to always use bin/crystal when developing the compiler, otherwise you will always use the old source code
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<zamith> I think I broke bin/crystal
<zamith> :P
<zamith> was trying to compile it with the 0.5.8 release
<zamith> i have an idea
<zamith> I just checked out to master and built it here
<zamith> ;)
<jhass> >> module A; end; class B; include A; end; class D(T); end; a = [] of D(A); a << D(B).new
<CeBot> jhass: [#<D(B):0x95C4FF8>]
<jhass> ^ that works fine
<jhass> no overload matches 'Array({Framework::PluginContainer(Framework::Plugin), Array(String)})#<<' with types {Framework::PluginContainer(Google), Array(String)}
<jhass> Overloads are:
<jhass> - Array({Framework::PluginContainer(Framework::Plugin), Array(String)})#<<(value : {Framework::PluginContainer(Framework::Plugin), Array(String)})
<jhass> Google includes Framework::Plugin
<asterite> I see. I guess the tuple there is the one leading to the error
<jhass> so not me wanting to much again? :P
<jhass> >> module A; end; class B; include A; end; class D(T); def initialize(@v : T); end; end; a = [] of {D(A), String}; a << {D.new(B.new), "foo"}
<CeBot> jhass: Error in line 3: no overload matches 'Array({D(A), String})#<<' with types {D(B), String}
<jhass> ah, indeed
<asterite> I think a reduced case is this: https://gist.github.com/asterite/96ed6780b96ba48bc89f
<asterite> But I don’t know how easy/hard is that to fix
<asterite> As a workaround, you can use a record
<jhass> thanks, will do
<asterite> I’ll open an issue anyway, it’s something to think about
<zamith> Is it easy to add any defined method in a describe block to be available in the scope of an example?
<asterite> how is that?
<asterite> Something like `describe “foo”; def helper;” ?
<zamith> yes
<zamith> so that I don't have to make all the helpers global to every test
<zamith> they can be scoped
<jhass> mmh, def foo(*args); end; macro foo(*args); foo({{*args}}); end; foo({'a', 'b'}) segfaults :/
<asterite> zamith: there’s no way to do exaclty what you want, but you can declare a top-level method as private
<asterite> That will make it available to only that file
<zamith> hum...
<zamith> will do
<asterite> jhass: I think that’s a stack overflow at compile-time :-P
<jhass> ah, right xD
<zamith> also, is there a way to move the helper to the bottom of the file?
<zamith> it's annoying to have to read it, in order to read the rest of the tests, but other than that it's fine
<asterite> zamith: no :(
<zamith> nevermind
<zamith> ;)
<zamith> almost done
<zamith> :)
<zamith> I'm doing symbol arrays as well
<asterite> zamith: you mean the colors in a white background are not very good?
<asterite> With %i(...), right?
<zamith> yes
<zamith> what colors?
<zamith> :S
<jhass> >> def foo(*args); end; macro bar(args=Tuple.new); foo({{*args}}); end; bar({'a', 'b'})
<CeBot> jhass: in line 3: undefined macro method TupleLiteral#argify'
<asterite> Ah, sorry, I just began reading it. It’s interesting the way it’s done. I think jhass wanted to do it that way too but we ran into some issues
<jhass> yeah, the "running code in the context of this random instance" aka with yield is too limited
<asterite> jhass: that’s a “bug” (you should be able to splat a tuple)
<jhass> >> def foo(*args); end; macro bar(args=Tuple.new); foo({{*args}}); end; bar()
<asterite> BTW, if you use an array, like bar([‘a’, ‘b’]) it works (and its the same, they are just AST nodes for the macros)
<CeBot> jhass: Error in line 3: undefined macro method StringLiteral#argify'
<jhass> asterite: what do I use for the default though?
<asterite> [] of Void :s ?
<asterite> Gotta go… bye!
asterite has quit [Quit: asterite]
<jhass> works ;)
<zamith> added support for %w[a b c] and the likes
<zamith> ;)
zamith has quit [Quit: Be back later ...]
sferik has joined #crystal-lang
zamith has joined #crystal-lang
leafybasil has joined #crystal-lang
travis-ci has joined #crystal-lang
<travis-ci> manastech/crystal#1839 (master - 0b823b5 : Ary Borenszweig): The build passed.
travis-ci has left #crystal-lang [#crystal-lang]
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sferik has joined #crystal-lang
sferik has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sferik has joined #crystal-lang