Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with raven.cr and Hash/Array inheritance #49

Open
mamantoha opened this issue May 12, 2019 · 1 comment
Open

Issue with raven.cr and Hash/Array inheritance #49

mamantoha opened this issue May 12, 2019 · 1 comment

Comments

@mamantoha
Copy link
Contributor

Hi.

I face an issue when trying to use raven.cr with jennifer.cr.

Module validation failed: Function return type does not match operand type of return inst!
  ret %"(Array(AnyHash::JSONTypes::Value) | Bool | Float32 | Float64 | Hash(String | Symbol, AnyHash::JSONTypes::Value)+ | Int128 | Int16 | Int32 | Int64 | Int8 | JSON::Any | Set(AnyHash::JSONTypes::Value) | String | Symbol | Time | UInt128 | UInt16 | UInt32 | UInt64 | UInt8 | Nil)" %1, !dbg !21
 %"(Array(AnyHash::JSONTypes::Value) | Bool | Float32 | Float64 | Hash(String | Symbol, AnyHash::JSONTypes::Value) | Int128 | Int16 | Int32 | Int64 | Int8 | JSON::Any | Set(AnyHash::JSONTypes::Value) | String | Symbol | Time | UInt128 | UInt16 | UInt32 | UInt64 | UInt8 | Nil)" = type { i32, [3 x i64] } (Exception)
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  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

I made some research, and this is the minimal code to reproduce this issue.

require "raven"

class MyHash(V) < Hash(String, V)
  # Code.
  # Actually, it doesn't matter.
end

begin
  1 / 0
rescue ex : DivisionByZeroError
  Raven.capture(ex)
end

The same with Array.

@Sija
Copy link
Owner

Sija commented May 12, 2019

Yep, that's a known limitation of raven.cr (yet inheriting from stdlib imo is a design smell).

I'd suggest to refactor the offending code with composition in mind.
For more information see:

PRs fixing this behavior are always welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants