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

Resolved fuzzer failures. #104

Merged
merged 1 commit into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,14 @@ func (ev *Eval) eval(exp primitive.Primitive, e *env.Environment, expandMacro bo
//
// Now we're only dealing with lists
//
listExp := exp.(primitive.List)
listExp, listOk := exp.(primitive.List)

//
// But just in case we're not ..
//
if !listOk {
return primitive.Error(fmt.Sprintf("argument not a list for a function call: %v", exp))
}

//
// Is this an empty list? Then just return it
Expand Down
4 changes: 4 additions & 0 deletions eval/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ a
{input: "(define blah (lambda (a:number) (print a))) (blah '(3))", output: "ERROR{TypeError - argument a to blah was supposed to be number, got list}"},
{input: "(define blah (lambda (a:function) (print a))) (blah '(3))", output: "ERROR{TypeError - argument a to blah was supposed to be function, got list}"},
{input: "(define blah (lambda (a:any) (print a))) (blah '(3))", output: "(3)"},

// fuzz errors
{input: "(defmacro! unless(fn*()`(~!)))(unless )", output: "ERROR{argument '(lambda (x) (if x #f #t))' not a function}"},
{input: "(ord 0)", output: "ERROR{argument not a character/string, got number}"},
}

for _, test := range tests {
Expand Down
1 change: 1 addition & 0 deletions fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func FuzzYAL(f *testing.F) {
"invalid character literal",
"is not a symbol",
"must have even length",
"not a character",
"not a function",
"not a hash",
"not a list",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
go test fuzz v1
[]byte("(defmacro! unless(fn*()`(~!)))(unless )")