Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type inference and SATISFIES, GUARD1, etc #133

Open
no-defun-allowed opened this issue Mar 30, 2022 · 2 comments
Open

Type inference and SATISFIES, GUARD1, etc #133

no-defun-allowed opened this issue Mar 30, 2022 · 2 comments

Comments

@no-defun-allowed
Copy link

no-defun-allowed commented Mar 30, 2022

I'd like to shift some more predicates into patterns, so that I can avoid a bunch of code that looks like (when (foo-p bar) (trivia.next:next)). But, so far, Trivia seems to consider the use of predicates that don't correspond to types deserving of a full warning.

A little example is:

CL-USER> (trivia:match 2
           ((satisfies evenp) 'even))
WARNING: failed to infer the type from test (EVENP ?) !
WARNING: failed to infer the type from test (EVENP ?) !
WARNING: failed to infer the type from test (EVENP ?) !
EVEN

There isn't a type that corresponds to the set of values which satisfy evenp, so I am not sure what I can do to avoid the warning. The same also happens with guard1:

CL-USER> (trivia:defpattern even-number ()
           `(trivia:guard1 (x) (evenp x)))
#<FUNCTION 'EVEN-NUMBER {52E5A57B}>
CL-USER> (trivia:match 2
           ((even-number) 'even))
WARNING: failed to infer the type from test (EVENP ?) !
WARNING: failed to infer the type from test (EVENP ?) !
WARNING: failed to infer the type from test (EVENP ?) !
EVEN

(Also, I'd guess the function name for the pattern should just be even-number - sb-int:named-lambda doesn't evaluate the name provided to it.)

Is signalling a full warning intended behaviour for Trivia? Can I write a pattern for some arbitrary test expression which doesn't signal a full warning at compile time? I ask since, in the end, I want to clean up some tests in the rewriter of one-more-re-nightmare, but I want to submit it to Quicklisp, and (to my knowledge) I cannot do so if compilation signals full warnings.

@guicho271828
Copy link
Owner

It is part of type-i so the issue should go there

@guicho271828
Copy link
Owner

For namedlambda thanks, will fix

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

No branches or pull requests

2 participants