Skip to content

If behaviour on stuck terms #239

Description

@o-santi

Currently, the (If ...) rule on the genesis block evaluates everything that is strictly not #0 to the true branch. This includes terms that cannot reduce any further, which can cause some very unexpected behaviour when comparing objects of different types.

For example, the following code:

fun (Test x) {
  (Test x) = (If (== x #5) (Done 'yay') (Fail #0))
}

run {
  ask test = (Call 'Test' [#4])
  (Done test)
}

will silently fail. It will always evaluate to (Done 'yay') even though it clearly is not the intended semantics, because the following comparison (== {T1 #4} #5) gets stuck, and If evaluates that to true.

I do believe that we should change it match only on #0 and #1, in order to avoid javascript-esque errors like these. But I think that this raises a bigger question: what should be the norm/expected behaviour on treating stuck terms?

cc @steinerkelvin @developedby

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions