Skip to content

Commit 0756c87

Browse files
committed
Allow for variables with unknown types
1 parent eefaad3 commit 0756c87

File tree

7 files changed

+12
-7
lines changed

7 files changed

+12
-7
lines changed

src/compiler.py

-2
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,6 @@ def unify(self, node, *values):
359359
def declare(self, node, type, id, redeclare=False, initialize=False, check_only=False):
360360
if type == tVoid:
361361
self.throw(node, err.InvalidDeclaration(type))
362-
if type.isUnknown():
363-
self.throw(node, err.UnknownType())
364362
if id in self.env and not redeclare:
365363
self.throw(node, err.RedeclaredIdentifier(id))
366364
if check_only:

test/bad/arrays/empty01.err

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Cannot settle type of the expression.
1+
Illegal assignment from `[Int]` to `[<Unknown>]`.

test/bad/arrays/empty01.px

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11

22
a = []
3+
a = [3]

test/bad/arrays/empty02.err

-1
This file was deleted.

test/bad/arrays/empty02.px

-3
This file was deleted.

test/good/generics/complex07.out

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
0
2+
6

test/good/generics/complex07.px

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
func length<T>([T] a) Int def
3+
if a.length == 0 do
4+
return 0
5+
return length(a[1:]) + 1
6+
7+
print length([])
8+
print length([1, 2] * 3)

0 commit comments

Comments
 (0)