Skip to content

Commit

Permalink
fix(checker): ensure fun param type exists
Browse files Browse the repository at this point in the history
  • Loading branch information
serkonda7 committed Dec 27, 2023
1 parent 30daa9a commit c351e09
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes will be documented in this file.
> Right now Bait is in an Alpha State (`0.0.x`). Breaking changes might occur anytime.

## 0.0.7
_unreleased_

### Type Checks
- Ensure function parameter type exists


## 0.0.6
_26 December 2023_

Expand Down
4 changes: 4 additions & 0 deletions lib/bait/checker/fun.bt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ fun (c Checker) fun_params(params []ast.Param){
}

sym := c.table.get_sym(p.typ)
if not c.does_type_exist(sym, p.pos) {
continue
}

if sym.kind == .fun_ {
c.scope.register(p.name, ast.ScopeObject{
typ = p.typ
Expand Down
1 change: 0 additions & 1 deletion tests/out/error/other/unknown_type.in.bt

This file was deleted.

1 change: 0 additions & 1 deletion tests/out/error/other/unknown_type.out

This file was deleted.

6 changes: 6 additions & 0 deletions tests/out/error/type/unknown.in.bt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// fun params
fun foo (y MyType) {

// casting
x := 1 as u7
}
2 changes: 2 additions & 0 deletions tests/out/error/type/unknown.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests/out/error/type/unknown.in.bt:2:9 error: unknown type MyType
tests/out/error/type/unknown.in.bt:5:8 error: unknown type u7

0 comments on commit c351e09

Please sign in to comment.