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

(session) compose session hash #12

Merged

Conversation

jackturnbull
Copy link
Contributor

Currently seeing a compiler bug when attempting to compile with raven.cr. Although I'm not convinced entirely that this is an issue with action-controller, it does seem to be considered good practice to stick with composition rather than inheritence for this sort of stuff (crystal-lang/crystal#3238 (comment)).

The approach taken was effectively the same as amberframework/amber#930 which fixed the same issue within Amber.

Previously, the following:

require "raven"
require "action-controller"

Raven.configure do |settings|
  settings.async = true
end

Causes the compiler panic:

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
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 Crystal::CodeGenVisitor#finish:Nil
  from Crystal::Compiler#codegen<Crystal::Program, Crystal::ASTNode+, Array(Crystal::Compiler::Source), String>:(Tuple(Array(Crystal::Compiler::CompilationUnit), Array(String)) | Nil)
  from Crystal::Compiler#compile<Array(Crystal::Compiler::Source), String>:Crystal::Compiler::Result
  from Crystal::Command#run_command<Bool>:Nil
  from Crystal::Command#run:(Bool | Crystal::Compiler::Result | Nil)
  from main

@@ -22,6 +22,9 @@ class ActionController::Session < Hash(String, String | Int64 | Float64 | Bool)
getter modified : Bool
property domain : String?
@encoder : MessageEncryptor | MessageVerifier
@store : Hash(String, String | Int64 | Float64 | Bool)

forward_missing_to @store

def initialize
super
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this call to super

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@stakach
Copy link
Member

stakach commented Sep 2, 2019

Looks like a great solution - had no idea forward_missing_to was a feature

@stakach
Copy link
Member

stakach commented Sep 2, 2019

Can you remove the call to super and I'll merge

Currently seeing a compiler bug when attempting to compile with raven.cr. Although I'm not convinced entirely that this is an issue with action-controller, it does seem to be considered good practice to stick with composition rather than inheritence for this sort of stuff (crystal-lang/crystal#3238 (comment)).

The approach taken was effectively the same as amberframework/amber#930 which fixed the same issue within Amber.
@jackturnbull jackturnbull force-pushed the bugfix/compose-session-hash branch from 25062a6 to 7de5f29 Compare September 2, 2019 09:37
@jackturnbull
Copy link
Contributor Author

Thanks for getting onto it so quickly! Didn't expect that at all :)

@stakach stakach merged commit f822694 into spider-gazelle:master Sep 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants