aboutsummaryrefslogtreecommitdiff
path: root/src/ast.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast.c')
-rw-r--r--src/ast.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/ast.c b/src/ast.c
index d258b91..056cc73 100644
--- a/src/ast.c
+++ b/src/ast.c
@@ -30,9 +30,15 @@
static struct src_loc loc_span(struct ast_node *left, struct ast_node *right)
{
struct src_loc loc = {0};
- if (!left || !right)
+ if (!left && !right)
return loc;
+ if (!left && right)
+ return right->loc;
+
+ if (left && !right)
+ return left->loc;
+
/* this might eventually be a good thing to do,
* but right now I'm still having issues with initializing all nodes
* with some kind of even slightly accurate location