diff options
author | 2021-05-12 13:00:25 -0700 | |
---|---|---|
committer | 2021-05-12 13:00:25 -0700 | |
commit | c09d7cf83905111ef7af9ee5bbd523f56664395c (patch) | |
tree | 84fed91f8f6522594b109c09140f69d9c39ff598 /src/js_ast.zig | |
parent | f8131f42bcd039964586cbf3bd019dc9a449c438 (diff) | |
download | bun-c09d7cf83905111ef7af9ee5bbd523f56664395c.tar.gz bun-c09d7cf83905111ef7af9ee5bbd523f56664395c.tar.zst bun-c09d7cf83905111ef7af9ee5bbd523f56664395c.zip |
That's all the errors??
Former-commit-id: f9a74df73d2831bfdd8e6f1c0e5c999ea300fc0d
Diffstat (limited to 'src/js_ast.zig')
-rw-r--r-- | src/js_ast.zig | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/js_ast.zig b/src/js_ast.zig index 6a93310a2..66954a5bb 100644 --- a/src/js_ast.zig +++ b/src/js_ast.zig @@ -938,7 +938,7 @@ pub const E = struct { } }, string => { - return strings.utf16EqlString(other.utf8, s.value); + return strings.utf16EqlString(s.value, other); }, JavascriptString => { return std.mem.eql(u16, other.value, s.value); @@ -1381,13 +1381,15 @@ pub const Expr = struct { pub const Query = struct { expr: Expr, loc: logger.Loc }; - pub fn getProperty(expr: *Expr, name: string) ?Query { - const obj: *E.Object = expr.data.e_object orelse return null; + pub fn getProperty(expr: *const Expr, name: string) ?Query { + if (std.meta.activeTag(expr.data) != .e_object) return null; + const obj: *E.Object = expr.data.e_object; for (obj.properties) |prop| { const value = prop.value orelse continue; const key = prop.key orelse continue; - const key_str: *E.String = key.data.e_string orelse continue; + if (std.meta.activeTag(key.data) != .e_string) continue; + const key_str: *E.String = key.data.e_string; if (key_str.eql(string, name)) { return Query{ .expr = value, .loc = key.loc }; } @@ -1396,16 +1398,20 @@ pub const Expr = struct { return null; } - pub fn getString(expr: *Expr, allocator: *std.mem.Allocator) !?string { - const key_str: *E.String = expr.data.e_string orelse return null; + pub fn getString(expr: *const Expr, allocator: *std.mem.Allocator) ?string { + if (std.meta.activeTag(expr.data) != .e_string) return null; - return if (key_str.isUTF8()) key_str.value else key_str.string(allocator); + const key_str: *E.String = expr.data.e_string; + + return if (key_str.isUTF8()) key_str.utf8 else key_str.string(allocator) catch null; } pub fn getBool( - expr: *Expr, + expr: *const Expr, ) ?bool { - const obj: *E.Boolean = expr.data.e_boolean orelse return null; + if (std.meta.activeTag(expr.data) != .e_boolean) return null; + + const obj = expr.data.e_boolean; return obj.value; } |