From ca4120afec54fc20295a4a7d3ce6f8c29eccd84c Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Thu, 13 May 2021 17:44:50 -0700 Subject: bug fixes galore Former-commit-id: 72439452918caa05a32d4e3607910901fa2f4f85 --- src/ast/base.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/ast') diff --git a/src/ast/base.zig b/src/ast/base.zig index 9e42818de..904ad97bd 100644 --- a/src/ast/base.zig +++ b/src/ast/base.zig @@ -33,6 +33,9 @@ pub const Ref = packed struct { .inner_index = std.math.maxInt(Ref.Int), .source_index = std.math.maxInt(Ref.Int), }; + pub fn toInt(int: anytype) Int { + return std.math.cast(Ref.Int, int) catch 0; + } pub fn isNull(self: *const Ref) bool { return self.source_index == std.math.maxInt(Ref.Int) and self.inner_index == std.math.maxInt(Ref.Int); } @@ -41,7 +44,7 @@ pub const Ref = packed struct { return self.source_index == std.math.maxInt(Ref.Int); } - pub fn isSourceIndexNull(int: Ref.Int) bool { + pub fn isSourceIndexNull(int: anytype) bool { return int == std.math.maxInt(Ref.Int); } -- cgit v1.2.3