From da049de285e58126a8e2e450b38f95c459884972 Mon Sep 17 00:00:00 2001 From: raskad <32105367+raskad@users.noreply.github.com> Date: Sun, 8 Sep 2024 01:56:44 +0200 Subject: [PATCH] fix docs and fuzzer errors --- core/ast/src/function/mod.rs | 2 +- tests/fuzz/fuzz_targets/parser-idempotency.rs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/ast/src/function/mod.rs b/core/ast/src/function/mod.rs index c35ac17282b..2cf0eb26dae 100644 --- a/core/ast/src/function/mod.rs +++ b/core/ast/src/function/mod.rs @@ -55,7 +55,7 @@ use crate::{ /// A Function body. /// -/// Since [`Script`] and `FunctionBody` has the same semantics, this is currently +/// Since `Script` and `FunctionBody` have the same semantics, this is currently /// only an alias of the former. /// /// More information: diff --git a/tests/fuzz/fuzz_targets/parser-idempotency.rs b/tests/fuzz/fuzz_targets/parser-idempotency.rs index af9f2bf15c2..a27582ed725 100644 --- a/tests/fuzz/fuzz_targets/parser-idempotency.rs +++ b/tests/fuzz/fuzz_targets/parser-idempotency.rs @@ -4,6 +4,7 @@ mod common; use crate::common::FuzzData; use boa_interner::ToInternedString; +use boa_ast::scope::Scope; use boa_parser::{Parser, Source}; use libfuzzer_sys::{fuzz_target, Corpus}; use std::{error::Error, io::Cursor}; @@ -15,11 +16,11 @@ fn do_fuzz(mut data: FuzzData) -> Result<(), Box> { let original = data.ast.to_interned_string(&data.interner); let mut parser = Parser::new(Source::from_reader(Cursor::new(&original), None)); - + let scope = Scope::new_global(); let before = data.interner.len(); // For a variety of reasons, we may not actually produce valid code here (e.g., nameless function). // Fail fast and only make the next checks if we were valid. - if let Ok(first) = parser.parse_script(&mut data.interner) { + if let Ok(first) = parser.parse_script(&mut data.interner, &scope) { let after_first = data.interner.len(); let first_interned = first.to_interned_string(&data.interner); @@ -33,10 +34,11 @@ fn do_fuzz(mut data: FuzzData) -> Result<(), Box> { first ); let mut parser = Parser::new(Source::from_reader(Cursor::new(&first_interned), None)); + let second_scope = Scope::new_global(); // Now, we most assuredly should produce valid code. It has already gone through a first pass. let second = parser - .parse_script(&mut data.interner) + .parse_script(&mut data.interner, &second_scope) .expect("Could not parse the first-pass interned copy."); let second_interned = second.to_interned_string(&data.interner); let after_second = data.interner.len();