fix: prevent obsolete typed-functions from hanging around

In other words, if name a depends on b and b is invalidated (because
  of added implementations), then a must be invalidated as well.

  Also adds a specific test (custom/piecemeal) that tests this.
This commit is contained in:
Glen Whitney 2022-07-19 11:48:52 -07:00
parent 66cbccfbbe
commit 4999cad775
3 changed files with 35 additions and 2 deletions

View file

@ -1,4 +1,8 @@
import './Complex.mjs'
import {numComplex} from './Complex.mjs'
export const negate = {
Complex: [['self'], ref => z => ({re: ref.self(z.re), im: ref.self(z.im)})]
/* need a "base case" to avoid infinite self-reference */
Complex: [['self'], ref => z => {
if (numComplex(z)) return {re: -z.re, im: -z.im}
return {re: ref.self(z.re), im: ref.self(z.im)}
}]
}