We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a601192 commit 7e6e6f5Copy full SHA for 7e6e6f5
compiler/compiler.go
@@ -403,6 +403,10 @@ func (c *compiler) StringNode(node *ast.StringNode) {
403
}
404
405
func (c *compiler) ConstantNode(node *ast.ConstantNode) {
406
+ if node.Value == nil {
407
+ c.emit(OpNil)
408
+ return
409
+ }
410
c.emitPush(node.Value)
411
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 {
705
ph := c.emit(OpJumpIfNil, placeholder)
706
c.chains[len(c.chains)-1] = append(c.chains[len(c.chains)-1], ph)
707
0 commit comments