Reproduced with GNU bash 3.2.57 on macOS and GNU bash 5.2.21 on Ubuntu 24.04. A script missing its fi, its done or a function's closing brace stopped with "script.sh: line N: syntax error: unexpected end of file" and exit code 2, where N is one past the last line. Both versions printed the same.
Two causes do not look like missing code. A script saved with Windows line endings failed the same way, because the final fi was really fi followed by a carriage return, which bash does not recognise. And a here-document whose closing EOF line was indented with spaces swallowed the rest of the file, including the fi after it; bash 5.2 first printed a warning that the here-document starting at line 2 was "delimited by end-of-file" because it never found its EOF line, which points straight at the cause.
An unclosed quote is reported differently: "unexpected EOF while looking for matching", followed by the quote character, at the line where the quote opened.