The Crystal Programming Language Forum

BUG: trying to downcast DB::ResultSet+ <- SQLite3::ResultSet (Exception) #9594

crystal -v
Crystal 0.35.1 [5999ae2] (2020-06-19)

LLVM: 8.0.0
Default target: x86_64-unknown-linux-gnu

require "sqlite3"
require "db"

db =DB.open("sqlite3://luckdb")
db.query_all("SELECT * FROM movie") do |rs|
    rs.each do
        rs.column_names.each do
            ...
        end
    end
end

OUTPUT:

BUG: trying to downcast DB::ResultSet+ <- SQLite3::ResultSet (Exception)
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/cast.cr:541:5 in ‘downcast_distinct’
from …/…/…/…/…/crystal/src/indexable.cr:73:26 in ‘downcast’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:1156:17 in ‘visit’
from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2193:7 in ‘prepare_call_args_non_external’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/call.cr:57:7 in ‘visit’
from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2193:7 in ‘prepare_call_args_non_external’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/call.cr:57:7 in ‘visit’
from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:74:5 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2188:9 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2193:7 in ‘visit’
from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:74:5 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/semantic/bindings.cr:17:7 in ‘prepare_call_args_non_external’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/call.cr:57:7 in ‘visit’
from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:74:5 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:74:5 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2188:9 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2193:7 in ‘visit’
from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:74:5 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/exception.cr:92:7 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:628:9 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2193:7 in ‘visit’
from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:628:9 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2193:7 in ‘visit’
from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:628:9 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2193:7 in ‘visit’
from …/…/…/…/…/crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:628:9 in ‘accept’
from …/…/…/…/…/crystal/src/compiler/crystal/codegen/codegen.cr:2158:7 in ‘codegen’
from …/…/…/…/…/crystal/src/compiler/crystal/compiler.cr:172:16 in ‘compile’
from …/…/…/…/…/crystal/src/compiler/crystal/command.cr:295:3 in ‘run’
from …/…/…/…/…/crystal/src/compiler/crystal.cr:11:1 in ‘__crystal_main’
from …/…/…/…/…/crystal/src/crystal/main.cr:105:5 in ‘main’
from src/env/__libc_start_main.c:94:2 in ‘libc_start_main_stage2’
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
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

I know that my code is not useful but it will produce a bug :slight_smile: