Skip to content

Refactor/overhaul type system#6

Merged
chadsec1 merged 11 commits intomainfrom
refactor/overhaul-type-system
Apr 15, 2026
Merged

Refactor/overhaul type system#6
chadsec1 merged 11 commits intomainfrom
refactor/overhaul-type-system

Conversation

@chadsec1
Copy link
Copy Markdown
Owner

@chadsec1 chadsec1 commented Apr 15, 2026

This pull request overhauls the type system. Here are the main major changes, and their reasons:

Change: Variable declaration now always require explicit type.
Reason: Type inference is a source of subtle logic bugs, enforcing explicit types, ensures least amount of voodoo.. (i.e. programmer does own x = 1, and that type inferred is int8, and if he try to increment x beyond int8 capacity, it would overflow. Enforcing programmer always writes explicit types helps make those types of bugs visible). Unfortunately though, type inference is still used internally within the compiler's semantic phase, and it has to be. This is a general problem that affects pretty much all compilers. Except our inference system now is less exposed, and simpler.

Change: Removal of the internal "Infer" type, which helps reduce bugs.
Reason: We previously had many guard statements around the codebase to prevent statements/expressions of type "Infer" from getting past semantic phase, removing "Infer" type completely reduces complexity, and bugs within compiler its self.

Change: Added more readable array syntax
Reason: Previous we had arrays like: own x int32[][] = int32[][ int32[1,2], int32[3,4] ] syntax, which is ugly once you get down to nested arrays like in that example. New syntax is much more readable: ```own x [][]int32 = [ [1,2], [3,4] ]

Change: Variable overshadowing is now not allowed at all
Reason: This will force programmers to write clean variable names, and will reduce logic bugs cased by implicit type conversions.

I also removed a lot of unused and duplicated functions. The code cyclic complexity metric should go down noticeably.

And I improved parser and semantic unit tests, made some also less brittle to changes.

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Apr 15, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics -25 complexity · -2 duplication

Metric Results
Complexity -25
Duplication -2

View in Codacy

🟢 Coverage 94.00% diff coverage · -0.52% coverage variation

Metric Results
Coverage variation -0.52% coverage variation (-1.00%)
Diff coverage 94.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (cb37266) 1801 1627 90.34%
Head commit (1da860a) 1749 (-52) 1571 (-56) 89.82% (-0.52%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6) 150 141 94.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

TIP This summary will be updated as you push new changes. Give us feedback

@chadsec1 chadsec1 merged commit c0a5e11 into main Apr 15, 2026
7 checks passed
@chadsec1 chadsec1 deleted the refactor/overhaul-type-system branch April 25, 2026 19:40
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