summaryrefslogtreecommitdiff
path: root/hclsyntax/expression.go
diff options
context:
space:
mode:
authorAnsgar Mertens <ansgar@hashicorp.com>2024-03-12 09:36:49 +0100
committerAnsgar Mertens <ansgar@hashicorp.com>2024-03-12 09:36:49 +0100
commit1cbb0d41b1499559bd3dddc37d6873c28f179952 (patch)
treef045fc6d1cb12e38608b067d7b687e01c7b49a40 /hclsyntax/expression.go
parent57f8bbf184a628a6dedb36520db1c90bfab7fb06 (diff)
feat: return ExprSyntaxError instead of nil when expression parsing fails for namespaced functions
Diffstat (limited to 'hclsyntax/expression.go')
-rw-r--r--hclsyntax/expression.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/hclsyntax/expression.go b/hclsyntax/expression.go
index c4a353c..63bd24c 100644
--- a/hclsyntax/expression.go
+++ b/hclsyntax/expression.go
@@ -2013,3 +2013,26 @@ func (e *AnonSymbolExpr) Range() hcl.Range {
func (e *AnonSymbolExpr) StartRange() hcl.Range {
return e.SrcRange
}
+
+// ExprSyntaxError is a placeholder for an invalid expression that could not
+// be parsed due to syntax errors.
+type ExprSyntaxError struct {
+ Placeholder cty.Value
+ ParseDiags hcl.Diagnostics
+}
+
+func (e *ExprSyntaxError) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
+ return e.Placeholder, e.ParseDiags
+}
+
+func (e *ExprSyntaxError) walkChildNodes(w internalWalkFunc) {
+ // ExprSyntaxError is a leaf node in the tree
+}
+
+func (e *ExprSyntaxError) Range() hcl.Range {
+ return hcl.Range{}
+}
+
+func (e *ExprSyntaxError) StartRange() hcl.Range {
+ return hcl.Range{}
+}