bel icon indicating copy to clipboard operation
bel copied to clipboard

Invalidate fastfuncs whose dependencies are overridden

Open masak opened this issue 5 years ago • 5 comments

I should find a nice small example (of a fastfunc that should change behavior when some other fastfunc that has been inlined into it gets overridden). Until then, just noting that this is currently a bug, as in, we're not to spec on this one.

masak avatar Jun 11 '20 01:06 masak

I should find a nice small example

dedup is the only function that uses foldl; therefore, if foldl were redefined to always return nil, dedup should always return nil — if it doesn't, that's a fastfunc-related bug.

masak avatar Jul 21 '20 08:07 masak

The problem is, right now, it actually works:

> (dedup '(a b c c b a c))
(a b c)
> (def foldl (f base . args) nil)
(lit clo nil (f base . args) nil)
> (foldl cons nil '(1 2 3 4 5))
nil
> (dedup '(a b c c b a c))
nil

Because we don't have a dedup fastfunc yet. In order to expose this bug, we'd need one first.

masak avatar Mar 28 '21 06:03 masak

In PR #313 (which has a dedup fastfunc), the problem now manifests:

> (dedup '(a b c c b a c))
(a b c)
> (def foldl (f base . args) nil)
(lit clo nil (f base . args) nil)
> (foldl cons nil '(1 2 3 4 5))
nil
> (dedup '(a b c c b a c))
(a b c)

masak avatar Mar 28 '21 07:03 masak

In PR #313 (which has a dedup fastfunc) [...]

...now merged, which means we have this problem on the master branch, too.

Incidentally, it's not altogether different from #170, which would also misbehave now under an appropriate test case:

> (bind foldl (fn (f base . args) nil) (dedup '(a b c c b a c)))
(a b c)

masak avatar Mar 28 '21 12:03 masak

breakc is another good example; its dependency is syntax, a global variable.

masak avatar Jun 24 '21 07:06 masak