Skip to content

Instantly share code, notes, and snippets.

@thbar
Created February 2, 2017 22:54
Show Gist options
  • Save thbar/92c2deaa5422b6fccb98a1132c333882 to your computer and use it in GitHub Desktop.
Save thbar/92c2deaa5422b6fccb98a1132c333882 to your computer and use it in GitHub Desktop.
require "./spec_helper"
alias ConfigValue = String | Int32
alias Config = Hash(Symbol, ConfigValue)
class SomeSource
@filename : String
def initialize(options : Config)
@filename = options[:filename]
end
end
c = Config.new
c[:filename] = "spec/fixtures/sample.csv"
source = SomeSource.new(c)
# Error in line 2: while requiring "./spec/repro_spec.cr"
#
# in spec/repro_spec.cr:16: instantiating 'SomeSource:Class#new(Hash(Symbol, Int32 | String))'
#
# source = SomeSource.new(c)
# ^~~
#
# in spec/repro_spec.cr:10: instance variable '@filename' of SomeSource must be String, not (Int32 | String)
#
# @filename = options[:filename]
# ^~~~~~~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment