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) {
403403}
404404
405405func (c * compiler ) ConstantNode (node * ast.ConstantNode ) {
406+ if node .Value == nil {
407+ c .emit (OpNil )
408+ return
409+ }
406410 c .emitPush (node .Value )
407411}
408412
@@ -695,7 +699,9 @@ func (c *compiler) MemberNode(node *ast.MemberNode) {
695699 }
696700
697701 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 {
699705 ph := c .emit (OpJumpIfNil , placeholder )
700706 c .chains [len (c .chains )- 1 ] = append (c .chains [len (c .chains )- 1 ], ph )
701707 }
You can’t perform that action at this time.
0 commit comments