From ce75ca8367ccfb55b2576a81eb8adbb1d91b8930 Mon Sep 17 00:00:00 2001 From: s-ol Date: Fri, 14 Aug 2020 15:54:23 +0200 Subject: bugfixes with compound type comparisons --- alv/result/evt.moon | 5 +++-- alv/type.moon | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/alv/result/evt.moon b/alv/result/evt.moon index cdd0e83..90a975a 100644 --- a/alv/result/evt.moon +++ b/alv/result/evt.moon @@ -12,7 +12,7 @@ class EvtStream extends Result --- return whether this Result was changed in the current tick. -- @treturn bool - dirty: => @updated == COPILOT.T + dirty: => @updated == (COPILOT and COPILOT.T) --- get the sequence of current events (if any). -- @@ -37,7 +37,8 @@ class EvtStream extends Result __call: (...) => @unwrap ... __tostring: => - "<#{@type}#{@metatype} #{if @dirty then @type\pp @value else 'nil'}>" + value = if @dirty! then @type\pp @value else 'nil' + "<#{@type}#{@metatype} #{value}>" --- the type of this Result's value. -- @tfield type.Type type diff --git a/alv/type.moon b/alv/type.moon index 1b47b13..4f38e02 100644 --- a/alv/type.moon +++ b/alv/type.moon @@ -126,7 +126,7 @@ class Struct extends Type types[key] = @types[key] @@ types - __eq: (other) => same @types, other.types + __eq: (other) => other.__class == Struct and same @types, other.types __tostring: => inner = table.concat ["#{k}: #{v}" for k, v in opairs @types], ' ' "{#{inner}}" @@ -161,7 +161,7 @@ class Array extends Type assert key >= 0 and key < @size, Error 'index', "index '#{key}' out of range!" @type - __eq: (other) => @size == other.size and @type == other.type + __eq: (other) => other.__class == Array and @size == other.size and @type == other.type __tostring: => "#{@type}[#{@size}]" --- instantiate an Array type. -- cgit v1.2.3