crystal-lang / crystal

The Crystal Programming Language
https://crystal-lang.org
Apache License 2.0
19.35k stars 1.62k forks source link

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

Open Geo-7 opened 4 years ago

Geo-7 commented 4 years ago

crystal -v Crystal 0.35.1 [5999ae29b] (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.
Ragmaanir commented 4 months ago

I am getting the same error with postgres:

require "db"
require "pg"

db = DB.open("lol")

db.query_all("test") { |rs|
  rs.each {
    rs.each_column { |col|
    }
  }
}
BUG: trying to downcast DB::ResultSet+ (Crystal::VirtualType) <- PG::ResultSet (Crystal::NonGenericClassType) (Exception)
  from /crystal/src/compiler/crystal/codegen/cast.cr:521:5 in 'downcast_distinct'
  from /crystal/src/compiler/crystal/codegen/cast.cr:297:15 in 'downcast:extern'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:1284:17 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:28:11 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2409:7 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2392:9 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2392:9 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2392:9 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2392:9 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2392:9 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2392:9 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2392:9 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2392:9 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2392:9 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2392:9 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/exception.cr:92:7 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/enumerable.cr:510:7 in '??'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2392:9 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/enumerable.cr:510:7 in '??'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2392:9 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/enumerable.cr:510:7 in '??'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2392:9 in 'visit'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/enumerable.cr:510:7 in '??'
  from /crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from /crystal/src/compiler/crystal/codegen/codegen.cr:2362:7 in 'codegen'
  from /crystal/src/compiler/crystal/compiler.cr:202:16 in 'compile:combine_rpath'
  from /crystal/src/compiler/crystal/compiler.cr:195:56 in 'compile:combine_rpath'
  from /crystal/src/compiler/crystal/command.cr:239:5 in 'run'
  from /crystal/src/compiler/crystal.cr:11:1 in '__crystal_main'
  from /crystal/src/crystal/main.cr:129:5 in 'main'
  from src/env/__libc_start_main.c:95: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
Crystal 1.12.1 [4cea10199] (2024-04-11)

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