Sorting a date field after editing another field displays error

I have two fields, Date and B. After field B is edited, it automatically runs the following code:

field "Date"
sortup

This produces the error message “edit” is not a valid date.

Adding a wait 0 at the beginning corrects the issue.
I can reproduce this problem in B29 and B30.

Running Mojave.