Skip to content

Add third type to doc-formal#1011

Merged
vsbogd merged 2 commits intotrueagi-io:mainfrom
DaddyWesker:main
Aug 25, 2025
Merged

Add third type to doc-formal#1011
vsbogd merged 2 commits intotrueagi-io:mainfrom
DaddyWesker:main

Conversation

@DaddyWesker
Copy link
Contributor

Pre-pr behavior:

If some grounded function (or function, written in strdlib.metta) have implementation, but no documentation, then calling help! on it produces error:

> !(help! not)
[(Error (Error (@doc-formal (@item not) (@kind function) (@type (-> Bool Bool)) (@desc "No documentation")) IncorrectNumberOfArguments) "Cannot match @doc-formal structure"), (Error (Error (@kind function) BadType) "Cannot match @doc-formal structure")]

Which comes from get-doc-function, which implementation is:

(: get-doc-function (-> Atom Type %Undefined%))
(= (get-doc-function $name $type)
  (let $top-space (mod-space! top)
  (unify $top-space (@doc $name $desc (@params $params) $ret)
    (let $type' (if (== $type %Undefined%) (undefined-doc-function-type $params) (cdr-atom $type))
    (let ($params' $ret') (get-doc-params $params $ret $type')
      (@doc-formal (@item $name) (@kind function) (@type $type) $desc (@params $params') $ret')))
    (@doc-formal (@item $name) (@kind function) (@type $type) (@desc "No documentation")) )))

As it can be seen, on "else" branch of unify (@doc-formal (@item $name) (@kind function) (@type $type) (@desc "No documentation")) is being returned, but doc-formal breaks since there is only two types:

(: @doc-formal (-> DocItem DocKindFunction DocType DocDescription DocParameters DocReturn DocFormal))
(: @doc-formal (-> DocItem DocKindAtom DocType DocDescription DocFormal))

and none of them could be applied to this case. So, third type is being added here to prevent error.

Post-pr behavior:

> !(help! not)
Function not (type (-> Bool Bool)) No documentation
[()]

(note that I've commented out not's documentation in sake of demonstration).

@DaddyWesker DaddyWesker requested a review from vsbogd August 25, 2025 05:50
@vsbogd vsbogd merged commit 65fbc5b into trueagi-io:main Aug 25, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants