diff --git a/ast/index_expression.go b/ast/index_expression.go index 4cd9528..e1e65f1 100644 --- a/ast/index_expression.go +++ b/ast/index_expression.go @@ -11,6 +11,8 @@ type IndexExpression struct { Value Expression } +func (ie *IndexExpression) validIfCondition() bool { return true } + func (ie *IndexExpression) expressionNode() {} func (ie *IndexExpression) String() string { diff --git a/parser/parser_test.go b/parser/parser_test.go index a5477f5..e8d68ed 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -397,6 +397,15 @@ func Test_IfExpression_PrefixExpressions_InvalidCompar(t *testing.T) { r.Error(err, "syntax error: invalid if condition, got x = 1") } +func Test_IfExpression_With_Map_Array_Index(t *testing.T) { + r := require.New(t) + input := `<% if (flash["error"] ) { x } %>` + + _, err := Parse(input) + + r.NoError(err) +} + func Test_IfExpression_InfixExpressions_InvalidCompare(t *testing.T) { r := require.New(t) input := `<% if ( y == 1 && x = 1) { x } %>`