summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/04_modules/12_import_immutability
blob: 48a7fe270eeee3c4258c11c8df956cd3f9aaa4fe (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Module imports are read-only bindings to the exported module variables.

-- Testcase --
import { a } from "./files/test.uc";

a = 2;
-- End --

-- File test.uc --
export let a = 1;
-- End --

-- Args --
-R
-- End --

-- Expect stderr --
Syntax error: Invalid assignment to constant 'a'
In [stdin], line 3, byte 5:

 `a = 2;`
      ^-- Near here


-- End --


Aggregated module objects are read-only as well.

-- Testcase --
import * as mod from "./files/test.uc";

mod.a = 2;
-- End --

-- File test.uc --
export let a = 1;
-- End --

-- Args --
-R
-- End --

-- Expect stderr --
Type error: object value is immutable
In line 3, byte 9:

 `mod.a = 2;`
          ^-- Near here


-- End --