trueagi-io / hyperon-experimental

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

assertEqualToResult gives the same result for correct and incorrect pattern in dasgate example #653

Open CICS-Oleg opened 3 months ago

CICS-Oleg commented 3 months ago

Let's consider the following metta script:

!(import! &self das_gate)
!(bind! &das (new-das))

!(add-atom &das (Test (Test 2)))
!(add-atom &das (Best (Test 2)))
!(add-atom &das Test)

; option 1: 2-nd argument is what we expect from incorrectly working match. This test should be passed, but the program fails here
!(assertEqualToResult
   (match &das (Test $v2) (This $v2 works))
   ((This 2 works) (This (Test 2) works) (This 2 works)))

; option 2: 2-nd argument is what we expect from correctly working match. This test should be failed, and the program fails here
!(assertEqualToResult
   (match &das (Test $v2) (This $v2 works))
   ((This 2 works) (This (Test 2) works)))

The question is: why does program fail in option 1?

Necr0x0Der commented 3 months ago

First of all, we don't expect (This 2 works) as a result. It is just. wrong. We expect only top-level results for match. We may have a special function in das-gate to query all the matches, but it should be distinguished from match in space API.

As for your problem, its core cause is that das gate returns 2 not as a grounded object, but as a symbol. The question is what to do with it, but you can replace 2 with A for now, and it will work.