arr-ai / arrai

The ultimate data engine.
http://arr.ai
Apache License 2.0
20 stars 15 forks source link

Fallback question mark syntax doesn't work for RHS of bare dot expr #532

Closed orlade-anz closed 4 years ago

orlade-anz commented 4 years ago

Please do not post any internal, closed source snippets on this public issue tracker!

Description

The fallback syntax a.b?:c (get b in a if it exists else fall back to c) only works if a is not blank. .b works if b is present in the local scope of ., but .b?:c does not.

Workaround is to introduce a LHS: \x x.b?:c.

Steps to Reproduce

$ arrai eval '(a: 1) -> .b?:0'
INFO[0000] unconsumed input

.:1:13:
(a: 1) -> .b?:0 
$ arrai eval '(a: 1) -> \x x.b?:0'
0

However it works if the question mark follows a deeper symbol:

rrai eval '(a: (b: 1)) -> .a.b?:0'  
1

Expected behavior

arrai eval '(a: 1) -> .b?:0'
0

Your Environment

$ arrai info
Version    : DIRTY-v0.107.0
Git commit : 9b0f4570f8bc49a89650907b806e02f014e887d6
Date       : 2020-08-02T05:15:55Z
OS/arch    : darwin/amd64
Go version : go1.14.4 darwin/amd64
orlade-anz commented 4 years ago

Dupe of #540