How to convert a string to ip-prefix data type?

Lets create a dynamic address list entry first:

/ip firewall address-list add list=test_list comment=test_comment dynamic=yes address=10.0.0.0/8

Now, any one has any idea why do i get false response when i issue:

:put (10.0.0.1 in [/ip firewall address-list get [find comment=test_comment] address])

when at the very time, issuing

:put (10.0.0.1 in 10.0.0.0/8)

would give me true ?
Also, using :toip , did not make any difference
unless i’m missing something, this seems like a bug to me

Edit: Upon further investigation, i believe the problem is that “/ip firewall address-list get ..” , gives back a string data type while the ‘in’ operator, requires either ip or ip-prefix data type. we have :toip command to convert a string to ip. but it does not work for an ip string with prefix. so the question changes to: How to convert a string to ip-prefix data type?

Update: Just contacted MikroTik and they confirmed that this is an issue and said they’ll find a way to solve it.

If $ipp is a string containing an ip-prefix then [[:parse ":return ".$ipp]] returns that ip-prefix.

A function that does that conversion:

:global toipprefix do={:local result [[:parse ":return $1"]]; :return $result}

[$toipprefix “192.168.2.100/24”] will evaluate to ip-prefix 192.168.2.100/24

That’s a pretty clever solution. well done

I finally had the time to try this myself. How the hell did you come up with that? this is genius. I’m not even entirely sure why it works. and furthermore, why only when the parse command is enclosed with an extra ‘’ pair. You deserve a reputation point for this. unfortunately though, i don’t seem to be able to give any.
Thanks for taking the time to find this topic and respond to it.