Fork me on GitHub

Hi! I am not understanding why something like this works

  (me/with [%e-entidade (me/or (= e (me/pred symbol? ?e))
                               (= (me/pred symbol? ?e) e))
            %a-atributo (me/or (= a (me/pred keyword? ?a))
                               (= (me/pred keyword? ?a) a))
            %v-valor (me/or (= v (me/pred symbol? ?v))
                            (= (me/pred symbol? ?v) v))
            %v-args (me/or (me/pred symbol? ?v)) 
            %v-teste-unario ((me/pred function? !funcao-unaria) !param-function-unaria)
            %operador-binario (me/pred #{'< '> '<= '>= 'not=} !funcao-binaria)
            %v-teste-binario (%operador-binario %v-args !param-function-binaria)
            %v-teste-funcao (me/or %v-teste-unario %v-teste-binario)
            %v-expression (me/or %v-valor %v-teste-unario %v-teste-binario)]
           [%e-entidade %a-atributo %v-valor . %v-teste-funcao ..1]) :ok)
but if I add any other params in the the (me/or of %v-args, eg,
%v-args (me/or (me/pred symbol? ?v) a-symbol) 
I get an Unable to resolve symbol: ?v in this context What am I missing? Thanks in advance!


@nlessa Definitely looks like a bug. Will try to find some time today to dig into it.


I am a little confused as to what you are trying to accomplish though. Do you have an example of the data your are matching on?


Those = signs are not going to be doing what I think you want them to do.


So while I might be able to find the bug, I want to make sure you can accomplish your task as well.


Thanks, @jimmy! The symbols = appears in the grammar that is being rewrited. It's been working fine, only with this little problem with the me/or. The use case I am working is a transformation from rules expressed in Clara Rules to datalog clauses. Meander worked very well! I faced only this and another strange problem (but with workaround) . I will post later here the other problem I found.


Okay, cool. Just wanted to make sure that the = signs were meant to be literals.


Also great to hear that it is working for you. Interesting to see a transformation from clara to datalog. Hopefully we can help fix those remaining issues.


Okay so the fact that you get the error you do is a bug. But for %v-args (me/or (me/pred symbol? ?v)) if you want something else in the or you need to make sure it has ?v in it.

👍 4

If you add a pattern that includes ?v there you should be fine. We are clearly failing to detect that problem correctly though and so we generate bad code.


Ah, ok, understood!


@noprompt Just fyi. Looks like we consider ?v bound already because of %v-valor and so argument-lvrs is empty.


@jimmy Thanks for taking a look. Do you have a patch in mind or did you want me to take it from here?


I’m sure fixing this will probably fix other instances of this problem.


(I’ve encountered it once in the last couple months but didn’t have a chance to properly look into it.)


I haven't had a chance to think of a fix. Need to familiarize myself with that code. Just wanted to dump the little bit I found here.


Okay, cool. This is perfect. It saves a ton of time. 🙂