fez-lisp 1.5.81 → 1.5.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/baked/std.js +1 -1
- package/package.json +1 -1
- package/src/check.js +35 -5
- package/src/types.js +2 -2
package/package.json
CHANGED
package/src/check.js
CHANGED
@@ -228,6 +228,7 @@ export const typeCheck = (ast) => {
|
|
228
228
|
getSuffix(re[1][VALUE]) === PREDICATE_SUFFIX
|
229
229
|
) {
|
230
230
|
// ATOM ASSIGMENT PREDICATE ASSIGMENT
|
231
|
+
env[name][STATS][TYPE_PROP][1] = [PREDICATE]
|
231
232
|
env[name][STATS][RETURNS] = [ATOM, PREDICATE]
|
232
233
|
}
|
233
234
|
} else if (
|
@@ -645,6 +646,17 @@ export const typeCheck = (ast) => {
|
|
645
646
|
)
|
646
647
|
if (isLeaf(returns)) {
|
647
648
|
// TODO figure out what we do here
|
649
|
+
// this here is a variable WORD
|
650
|
+
// so return type of that function is that varible type
|
651
|
+
if (copy[returns[VALUE]])
|
652
|
+
ref[STATS][RETURNS] =
|
653
|
+
copy[returns[VALUE]][STATS][TYPE_PROP]
|
654
|
+
else
|
655
|
+
stack.push(() => {
|
656
|
+
if (copy[returns[VALUE]])
|
657
|
+
ref[STATS][RETURNS] =
|
658
|
+
copy[returns[VALUE]][STATS][TYPE_PROP]
|
659
|
+
})
|
648
660
|
} else {
|
649
661
|
const ret = returns[0]
|
650
662
|
switch (ret[VALUE]) {
|
@@ -658,6 +670,7 @@ export const typeCheck = (ast) => {
|
|
658
670
|
getSuffix(re[0][VALUE]) === PREDICATE_SUFFIX ||
|
659
671
|
getSuffix(re[1][VALUE]) === PREDICATE_SUFFIX
|
660
672
|
) {
|
673
|
+
ref[STATS][TYPE_PROP][1] = PREDICATE
|
661
674
|
ref[STATS][RETURNS][1] = PREDICATE
|
662
675
|
}
|
663
676
|
} else {
|
@@ -667,19 +680,35 @@ export const typeCheck = (ast) => {
|
|
667
680
|
const alternative = isLeaf(re[1])
|
668
681
|
? copy[re[1][VALUE]]
|
669
682
|
: copy[re[1][0][VALUE]]
|
683
|
+
|
670
684
|
// todo check if condition matches alternative
|
685
|
+
// TODO make this more simple - it's so many different things just because types are functions or not
|
686
|
+
// WHY not consiter making return types for everything
|
671
687
|
if (
|
672
688
|
concequent &&
|
673
|
-
concequent[STATS][
|
689
|
+
concequent[STATS][TYPE_PROP][0] !== UNKNOWN
|
674
690
|
) {
|
675
|
-
|
691
|
+
if (concequent[STATS][TYPE_PROP][0] === APPLY)
|
692
|
+
ref[STATS][RETURNS] = concequent[STATS][RETURNS]
|
693
|
+
else
|
694
|
+
ref[STATS][RETURNS] =
|
695
|
+
concequent[STATS][TYPE_PROP]
|
676
696
|
} else if (
|
677
697
|
alternative &&
|
678
|
-
alternative[STATS][
|
698
|
+
alternative[STATS][TYPE_PROP][0] !== UNKNOWN
|
679
699
|
) {
|
680
|
-
|
700
|
+
if (alternative[STATS][TYPE_PROP][0] === APPLY)
|
701
|
+
ref[STATS][RETURNS] =
|
702
|
+
alternative[STATS][RETURNS]
|
703
|
+
else
|
704
|
+
ref[STATS][RETURNS] =
|
705
|
+
alternative[STATS][TYPE_PROP]
|
681
706
|
} else if (concequent) {
|
682
|
-
|
707
|
+
if (concequent[STATS][TYPE_PROP][0] === APPLY)
|
708
|
+
ref[STATS][RETURNS] = concequent[STATS][RETURNS]
|
709
|
+
else
|
710
|
+
ref[STATS][RETURNS] =
|
711
|
+
concequent[STATS][TYPE_PROP]
|
683
712
|
}
|
684
713
|
}
|
685
714
|
|
@@ -694,6 +723,7 @@ export const typeCheck = (ast) => {
|
|
694
723
|
ref[STATS][RETURNS] =
|
695
724
|
copy[ret[VALUE]][STATS][RETURNS]
|
696
725
|
})
|
726
|
+
|
697
727
|
break
|
698
728
|
}
|
699
729
|
}
|
package/src/types.js
CHANGED
@@ -10,8 +10,8 @@ export const TYPE_PROP = 'type'
|
|
10
10
|
export const SIGNATURE = 'name'
|
11
11
|
export const ORDER = '__order__'
|
12
12
|
export const VARIABLE_ORDER_INDEX = 'index'
|
13
|
-
export const PREDICATE =
|
14
|
-
export const COLLECTION =
|
13
|
+
export const PREDICATE = 4
|
14
|
+
export const COLLECTION = 3
|
15
15
|
export const MAX_ARGUMENT_RETRY = 1
|
16
16
|
export const MAX_RETRY_DEFINITION = 10
|
17
17
|
export const toTypeNames = (type) => {
|