I want to refactor my shards to use polydocopt to rewrite the sub-command parser, but when I added this shards into my project, and requireing it, i get following strange compiler error when run shards buld
╰──➤ $ shards build
Dependencies are satisfied
Building: new_app
Error target new_app failed to compile:
BUG: called type_id for Array(Config)+.class (Crystal::VirtualMetaclassType) (Exception)
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '??'
from /home/zw963/Crystal/bin/crystal in '__crystal_main'
from /home/zw963/Crystal/bin/crystal in 'main'
from /usr/lib/libc.so.6 in '??'
from /usr/lib/libc.so.6 in '__libc_start_main'
from /home/zw963/Crystal/bin/crystal in '_start'
from ???
Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: https://github.com/crystal-lang/crystal/issues
Does it work if you make it use GitHub - ralsina/docopt.cr: docopt for crystal-lang via shards override instead of the original? This fork contains some bug fixes that the other shard was doing that was kinda frowned upon.
Usually this means you’re using a production binary that had debug symbols stripped.
As Blacksmoke16 said, this issue caused by inherit from Array, following is the diff screenshot for original old broken version(left) with forked working version(right)