diff options
author | 2021-05-13 17:44:50 -0700 | |
---|---|---|
committer | 2021-05-13 17:44:50 -0700 | |
commit | ca4120afec54fc20295a4a7d3ce6f8c29eccd84c (patch) | |
tree | 6619890c616bde65b3798b28fb99018b1eac71e3 /src/ast | |
parent | 2eb09c1fec3a11067066602e2d6613e817a06630 (diff) | |
download | bun-ca4120afec54fc20295a4a7d3ce6f8c29eccd84c.tar.gz bun-ca4120afec54fc20295a4a7d3ce6f8c29eccd84c.tar.zst bun-ca4120afec54fc20295a4a7d3ce6f8c29eccd84c.zip |
bug fixes galore
Former-commit-id: 72439452918caa05a32d4e3607910901fa2f4f85
Diffstat (limited to 'src/ast')
-rw-r--r-- | src/ast/base.zig | 5 |
1 files changed, 4 insertions, 1 deletions
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); } |