trueagi-io / hyperon-experimental

MeTTa programming language implementation
https://metta-lang.dev
MIT License
141 stars 47 forks source link

Fix nested variable operations #668

Closed vsbogd closed 2 months ago

vsbogd commented 5 months ago

Quick fix for #642

vsbogd commented 5 months ago

Thanks for checking Nil, I am sorry for that. It is not normal and this happens because tuples of variables are matched with random types. In this case ($x $y) tuple matches with (: (@kind atom) DocKindAtom) and (: (@kind function) DocKindFunction) type, which causes two different interpretation to be returned. It can be seen by executing:

!(get-type (($x $y) $y))
[(DocKindAtom %Undefined%), (DocKindFunction %Undefined%)]
vsbogd commented 5 months ago

The effect above is raised as issue #235

ngeiswei commented 5 months ago

I see, I can live with that for now, so if the duplicate issue is too difficult to fix now I'm happy to have that merged.

vsbogd commented 5 months ago

I don't want to merge it now, I would like to finish discussion in #642 first. Please see possible solution https://github.com/trueagi-io/hyperon-experimental/issues/642#issuecomment-2061567989

vsbogd commented 2 months ago

@ngeiswei , should be fixed now, please try it.

ngeiswei commented 2 months ago

With the latest revision 23a22d28

(= ((W $x) $y) (($x $y) $y))
!(($x $y) $y)

still spawns MeTTa in a infinite recursion (with variable_operation disabled).

ngeiswei commented 2 months ago

Oh, these are new commits, let me check then!

ngeiswei commented 2 months ago

It behaves as expected on my end.

ngeiswei commented 2 months ago

It's awesome to see these old issues being knocked down one by one! Thanks!