blob: 156fa0b39a93d5b2d755f413aac00f65df1eaf2d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
1. Nested functions should inherit constants from parent scopes, but not
local variables. At the moment the former works, but when trying to
(incorrectly) use a local variable from an outer scope in an inner
function, the compiler crashes:
foo :: () {
x := 42;
X :: 69;
bar :: () int { return x; } /* not fine; breaks */
baz :: () int { return X; } /* totally fine */
}
This is presumably due to the compiler maintaining a single tree of
scopes where a scope contains information for both constants and
variables. If this is indeed the cause, then there should most
probably be separate scope-trees; one which has scopes for constants,
and one which has scopes for variables.
2. Recursive functions crash the compiler.
foo :: () { return foo(); } /* breaks */
3. Global variables are broken both when being declared and assigned to
function calls and other globals. Both of these cased should be
illegal; globals if assigned at declaration should only be able to be
assigned to constant expressions.
foo :: () int { return 42; }
x := 5;
x′ := x; /* breaks */
x″ := foo(); /* breaks */
|