Skip to content

Commit

Permalink
fix(parser): throw a proper error when dimension of a fixed array is …
Browse files Browse the repository at this point in the history
…too large
  • Loading branch information
JaDogg committed Mar 2, 2024
1 parent c939f4f commit a407742
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
15 changes: 15 additions & 0 deletions compiler/fuzz.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
REM Run llvm-fuzzer
docker build -t yaksha .
CALL :NORMALIZEPATH ".\bin\coverage"
SET LOCAL_PATH=%RETVAL%
CALL :NORMALIZEPATH ".\bin\fuzz"
SET FUZZ_PATH=%RETVAL%
docker run -v "%LOCAL_PATH%:/coverage" -v "%FUZZ_PATH%:/fuzz" --rm -it --entrypoint /app/scripts/llvm-fuzzer.sh yaksha

:: Reference https://stackoverflow.com/a/33404867/1355145
:: ========== FUNCTIONS ==========
EXIT /B

:NORMALIZEPATH
SET RETVAL=%~f1
EXIT /B
2 changes: 2 additions & 0 deletions compiler/scripts/llvm-fuzzer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ cd /app || exit 1
mkdir build
mkdir bin
mkdir bin/fuzz
cp /app/test.txt bin/test.txt
find . -type f -exec dos2unix {} \;
cd test_data || exit 1
dos2unix *
cd ..
Expand Down
6 changes: 5 additions & 1 deletion compiler/src/ast/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,11 @@ ykdatatype *parser::parse_datatype() {
dt = dt_pool_->create(after_dot->token_, module_import_alias);
datatypes_from_modules_.emplace_back(dt);
} else if (tk->type_ == token_type::INTEGER_DECIMAL) {
dt = dt_pool_->create_dimension(tk, filepath_);
try {
dt = dt_pool_->create_dimension(tk, filepath_);
} catch (std::out_of_range &e) {
throw error(tk, "Integer value is out of range");
}
} else {
dt = dt_pool_->create(tk->token_, filepath_);
}
Expand Down

0 comments on commit a407742

Please sign in to comment.