Skip to content

Expand scope of narrowing typecasts and fix issues - #117

Open
kjw142857 wants to merge 21 commits into
mainfrom
type-casting
Open

kjw142857 wants to merge 21 commits into
mainfrom
type-casting

Conversation

@kjw142857

@kjw142857 kjw142857 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

This PR expands on #89 to enhance narrowing typecasts as well as fixing some known limitations.

Changes:

  • Byte, short and char now are able to be narrowcasted using the Java 8 typecasting rules
  • Fixed a grammar rule which was causing errors when performing a non-primitive (reference) narrrowing typecast.
  • Fixed a bug where narrowing typecasts rounded numbers (e.g. double to int) instead of truncating them.
  • Fixed a bug which allowed compilation of illegal binary operations between disallowed types.
  • Fixed a bug where an extra line would be printed after every print statment.
  • Fixed a bug where some primitive types would not be printed correctly.
  • Fixed a bug where break in a switch statement in a loop would break the loop instead of the switch.
  • Fixed a bug where instantiation of abstract classes succeeding in compiling, and added checks that all abstract methods in an abstract class are eventually implemented by its descendant concrete classes.
  • Fixed a bug where field access to a parent class using the super keyword could not compile.
  • Fixed a bug where calling an inherited method could not compile.
  • Fixed a bug where field initialisation of arrays could not compile.
  • Fixed a bug where inheritance from an imported library discarded the details of the import.
  • Fixed a bug where a bare this keyword could not be parsed.
  • Fixed an issue with checked exceptions and added support for throwing user-defined exceptions.
  • Fixed a bug where arrays could not be initialised with default values.
  • Fixed a bug where arrays could not be initialised with an explicit type definition.

@kjw142857
kjw142857 requested a review from martin-henz October 27, 2026 14:02
@kjw142857 kjw142857 changed the title Expand scope of narrowing typecasts and fix truncation Expand scope of narrowing typecasts and fix issues Oct 27, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Coverage report

St.❔
Category Percentage Covered / Total
🟡 Statements
76.59% (+4.79% 🔼)
10575/13808
🟡 Branches
65.17% (+4.87% 🔼)
3665/5624
🟡 Functions
75.75% (+5.43% 🔼)
1902/2511
🟡 Lines
77.49% (+4.78% 🔼)
9853/12716
Show new covered files 🐣
St.❔
File Statements Branches Functions Lines
🟢
... / StrictMath.ts
100% 100% 100% 100%
🟡 jvm/utils/fdlibm.ts 71.9% 43.09% 100% 74.77%
🟢
... / Double.ts
100% 100% 100% 100%
🟢
... / Float.ts
100% 100% 100% 100%
🟢
... / castExpression.test.ts
100% 100% 100% 100%
🟢
... / literals.test.ts
100% 100% 100% 100%
🟢
... / switch.test.ts
100% 100% 100% 100%
🟢
... / inheritance.test.ts
100% 100% 100% 100%
🟢
... / throw.test.ts
100% 100% 100% 100%
Show files with reduced coverage 🔻
St.❔
File Statements Branches Functions Lines
🔴
... / references.ts
58.42% (-0.09% 🔻)
41.96% 68%
58.68% (-0.09% 🔻)
🟢
... / compiler.ts
98.57% (-0.35% 🔻)
88.75% (+8.19% 🔼)
100%
98.96% (+0.11% 🔼)
🟢
... / constant-pool-manager.ts
98.86% (+0.15% 🔼)
91.67% (-2.78% 🔻)
96.77% (+0.22% 🔼)
98.85% (+0.15% 🔼)

Test suite run success

2310 tests passing in 78 suites.

Report generated by 🧪jest coverage report action from f8a93bf

@kjw142857 kjw142857 mentioned this pull request Nov 3, 2026
Comment thread src/compiler/code-generator.ts Resolved
Comment thread src/compiler/code-generator.ts Resolved
Comment thread src/compiler/code-generator.ts Resolved
Comment thread src/compiler/code-generator.ts Resolved
@kjw142857
kjw142857 requested a review from kellywsq03 November 5, 2026 16:32
Comment thread src/compiler/code-generator.ts Resolved
Comment thread src/compiler/code-generator.ts Resolved
Comment thread src/compiler/code-generator.ts Resolved
Comment thread src/compiler/symbol-table.ts Resolved
Comment thread src/compiler/code-generator.ts Resolved
kjw142857 and others added 3 commits November 10, 2026 21:54

This branch has not been deployed

No deployments
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.

3 participants