Skip to content

console.log: null strings and format placeholders; Math.round and parseFloat as JavaScript's - #130

Merged
ASDAlexander77 merged 2 commits into
mainfrom
node-output-fixes
Nov 30, 2026
Merged

ASDAlexander77 merged 2 commits into
mainfrom
node-output-fixes

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Found by comparing programs' output with Node's (compiler side: ASDAlexander77/TypeScriptCompiler#1080).

  • console.log of a null string read through it, a crash without strict null checks: it prints null
  • console.log fills %s %d %i %f %j %o %O %c from the arguments after the first, and %% is % (they were printed as they are)
  • Math.round rounds a half up, as JavaScript does: Math.round(-2.5) is -2 (C's round gave -3), and -0 between -0.5 and 0
  • parseFloat is NaN where the text has no number (strtod gave 0), reads no hexadecimal, and reads Infinity only when spelled so

New test tests/node_output_forms.ts.

Testing

  • tests/node_output_forms.ts and tests/string_concat.ts under gc, rc, none and own with the compiler of #1080
  • the full tests.ps1 run is in progress locally

🤖 Generated with Claude Code

ASDAlexander77 and others added 2 commits November 30, 2026 18:34
…seFloat as JavaScript's

Found by comparing programs' output with Node's:
- console.log of a null string printed through it (a crash without strict null checks): it is "null"
- console.log fills %s %d %i %f %j %o %O %c from the arguments after the first, and %% is "%"
- Math.round rounds a half up (Math.round(-2.5) is -2; C's round gave -3), -0 between -0.5 and 0
- parseFloat is NaN where the text has no number (strtod gave 0), reads no hexadecimal, and "Infinity" only
  spelled so

Needs the compiler of the same change (console.log arguments made strings in Node's inspect form).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… own test is 00number_conversion_forms)

Number("abc") is NaN only with the compiler of TypeScriptCompiler#1080, and this repository's CI tests with the
newest compiler release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit da4749f into main Nov 30, 2026
10 checks passed
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

Successfully merging this pull request may close these issues.

1 participant