File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -403,6 +403,10 @@ func (c *compiler) StringNode(node *ast.StringNode) {
403
403
}
404
404
405
405
func (c * compiler ) ConstantNode (node * ast.ConstantNode ) {
406
+ if node .Value == nil {
407
+ c .emit (OpNil )
408
+ return
409
+ }
406
410
c .emitPush (node .Value )
407
411
}
408
412
@@ -695,7 +699,9 @@ func (c *compiler) MemberNode(node *ast.MemberNode) {
695
699
}
696
700
697
701
c .compile (base )
698
- if node .Optional {
702
+ // If the field is optional, we need to jump over the fetch operation.
703
+ // If no ChainNode (none c.chains) is used, do not compile the optional fetch.
704
+ if node .Optional && len (c .chains ) > 0 {
699
705
ph := c .emit (OpJumpIfNil , placeholder )
700
706
c .chains [len (c .chains )- 1 ] = append (c .chains [len (c .chains )- 1 ], ph )
701
707
}
You can’t perform that action at this time.
0 commit comments