From bd5cadf2dea64ddb0498f51e1448793ecfbe9c87 Mon Sep 17 00:00:00 2001
From: "Sven M. Hallberg" <pesco@khjk.org>
Date: Sun, 9 Feb 2020 20:27:00 +0100
Subject: [PATCH] put a type assert macro for the sequence in H_INDEX/H_FIELD

this way the assert will fire from the user's code rather than the one in
glue.c:h_seq_index() which is not informative without a stack trace.
---
 src/glue.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/glue.h b/src/glue.h
index 31597cd2..fcad1231 100644
--- a/src/glue.h
+++ b/src/glue.h
@@ -247,7 +247,7 @@ HParsedToken *h_seq_index_vpath(const HParsedToken *p, size_t i, va_list va);
 #define H_INDEX_BYTES(SEQ, ...)  H_CAST_BYTES(H_INDEX_TOKEN(SEQ, __VA_ARGS__))
 #define H_INDEX_SINT(SEQ, ...)   H_CAST_SINT(H_INDEX_TOKEN(SEQ, __VA_ARGS__))
 #define H_INDEX_UINT(SEQ, ...)   H_CAST_UINT(H_INDEX_TOKEN(SEQ, __VA_ARGS__))
-#define H_INDEX_TOKEN(SEQ, ...)  h_seq_index_path(SEQ, __VA_ARGS__, -1)
+#define H_INDEX_TOKEN(SEQ, ...)  h_seq_index_path(H_ASSERT_SEQ(SEQ), __VA_ARGS__, -1)
 
 // Standard short-hand to access and cast elements on a sequence token.
 #define H_FIELD(TYP, ...)  H_INDEX(TYP, p->ast, __VA_ARGS__)
-- 
GitLab