Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/type_inference/common.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ class @Ti_context
@type_map= module.default_type_map_gen()
@library_map = {}

change_count_inc : ()->
@change_count++
@parent?.change_count_inc()
return

mk_nest : ()->
ret = new Ti_context
ret.parent = @
Expand Down Expand Up @@ -306,11 +311,11 @@ class @Ti_context
return a_type if !b_type
if !a_type and b_type
a_type = b_type.clone()
ctx.change_count++
ctx.change_count_inc()
else if a_type.main == "number"
if b_type.main in ["unsigned_number", "signed_number"]
a_type = b_type.clone()
ctx.change_count++
ctx.change_count_inc()
else if b_type.main == "number"
"nothing"
else
Expand All @@ -320,15 +325,15 @@ class @Ti_context
unless is_defined_number_or_byte_type b_type
throw new Error "can't spread '#{b_type}' to '#{a_type}'"
a_type = b_type.clone()
ctx.change_count++
ctx.change_count_inc()
else if @is_not_defined_type(a_type) and !@is_not_defined_type(b_type)
if a_type.main in ["unsigned_number", "signed_number"]
unless is_defined_number_or_byte_type b_type
throw new Error "can't spread '#{b_type}' to '#{a_type}'"
else
throw new Error "unknown is_not_defined_type spread case"
a_type = b_type.clone()
ctx.change_count++
ctx.change_count_inc()
else if !@is_not_defined_type(a_type) and @is_not_defined_type(b_type)
# will check, but not spread
if b_type.main in ["number", "unsigned_number", "signed_number"]
Expand Down