bad-place

`set` targets something that cannot be set.

compile error, shown by synod check.

You can set a local, a node field, or an element of one with set item … of. Hole parameters, when bindings, each names and record fields cannot be set. A local that was made outside an after block or a block argument cannot be set inside it, because the block holds a copy.

Example

Check this program to see the diagnostic.

# package p
define Next [k: number]
  set k to (k plus 1)
  result k

Diagnostic

p/p.synod:3:7: error[bad-place]: cannot set "k": it is a hole parameter

Fix

Set a local instead of the parameter.

# package p
define Next [k: number]
  set next to (k plus 1)
  result next