koatl 0.1.35__tar.gz → 0.1.36__tar.gz

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.
Files changed (121) hide show
  1. {koatl-0.1.35 → koatl-0.1.36}/Cargo.lock +1 -1
  2. {koatl-0.1.35 → koatl-0.1.36}/PKG-INFO +1 -1
  3. {koatl-0.1.35 → koatl-0.1.36}/koatl/Cargo.toml +1 -1
  4. {koatl-0.1.35 → koatl-0.1.36/koatl}/python/koatl/prelude/iterable.tl +15 -5
  5. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/src/resolve_scopes.rs +46 -14
  6. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/src/transform.rs +2 -1
  7. {koatl-0.1.35/koatl → koatl-0.1.36}/python/koatl/prelude/iterable.tl +15 -5
  8. {koatl-0.1.35 → koatl-0.1.36}/Cargo.toml +0 -0
  9. {koatl-0.1.35 → koatl-0.1.36}/README.md +0 -0
  10. {koatl-0.1.35 → koatl-0.1.36}/koatl/.github/workflows/CI.yml +0 -0
  11. {koatl-0.1.35 → koatl-0.1.36}/koatl/.gitignore +0 -0
  12. {koatl-0.1.35 → koatl-0.1.36}/koatl/LICENSE +0 -0
  13. {koatl-0.1.35 → koatl-0.1.36}/koatl/README.md +0 -0
  14. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/__init__.py +0 -0
  15. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/__main__.py +0 -0
  16. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/cli.py +0 -0
  17. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/notebook/__init__.py +0 -0
  18. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/notebook/magic.py +0 -0
  19. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/prelude/__init__.tl +0 -0
  20. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/prelude/functional/__init__.tl +0 -0
  21. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/prelude/functional/algebra.tl +0 -0
  22. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/prelude/functional/async.tl +0 -0
  23. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/prelude/functional/env.tl +0 -0
  24. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/prelude/functional/list.tl +0 -0
  25. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/prelude/functional/memo.tl +0 -0
  26. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/prelude/functional/result.tl +0 -0
  27. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/prelude/io.tl +0 -0
  28. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/prelude/regex.tl +0 -0
  29. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/runtime/__init__.py +0 -0
  30. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/runtime/classes.py +0 -0
  31. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/runtime/helpers.py +0 -0
  32. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/runtime/meta_finder.py +0 -0
  33. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/runtime/record.py +0 -0
  34. {koatl-0.1.35 → koatl-0.1.36}/koatl/python/koatl/runtime/virtual.py +0 -0
  35. {koatl-0.1.35 → koatl-0.1.36}/koatl/requirements.txt +0 -0
  36. {koatl-0.1.35 → koatl-0.1.36}/koatl/src/emit_py.rs +0 -0
  37. {koatl-0.1.35 → koatl-0.1.36}/koatl/src/lib.rs +0 -0
  38. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/coal.tl +0 -0
  39. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/containers.tl +0 -0
  40. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/data.txt +0 -0
  41. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/decorators.tl +0 -0
  42. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/destructure-for-and-fn.tl +0 -0
  43. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/destructure.tl +0 -0
  44. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/escape_ident.tl +0 -0
  45. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/fstr.tl +0 -0
  46. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/functions.tl +0 -0
  47. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/generator.tl +0 -0
  48. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/if_expr.tl +0 -0
  49. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/imports.tl +0 -0
  50. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/loops.tl +0 -0
  51. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/match.tl +0 -0
  52. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/nary-list.tl +0 -0
  53. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/placeholder.tl +0 -0
  54. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/precedence.tl +0 -0
  55. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/record.tl +0 -0
  56. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/scopes.tl +0 -0
  57. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/semantic_whitespace.tl +0 -0
  58. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/short_circuit.tl +0 -0
  59. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/base/with.tl +0 -0
  60. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/prelude/async.tl +0 -0
  61. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/prelude/aug_assign.tl +0 -0
  62. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/prelude/env.tl +0 -0
  63. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/prelude/iterables.tl +0 -0
  64. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/prelude/list.tl +0 -0
  65. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/prelude/memo.tl +0 -0
  66. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/prelude/result.tl +0 -0
  67. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/prelude/slice.tl +0 -0
  68. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/prelude/try.tl +0 -0
  69. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/prelude/virtual.tl +0 -0
  70. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/util/__init__.py +0 -0
  71. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/util/module0.tl +0 -0
  72. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/util/module1.tl +0 -0
  73. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/e2e/util/module2.tl +0 -0
  74. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/parse/arith.tl +0 -0
  75. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/parse/assign.tl +0 -0
  76. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/parse/block-comments.tl +0 -0
  77. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/parse/deco.tl +0 -0
  78. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/parse/func.tl +0 -0
  79. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/parse/matches.tl +0 -0
  80. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/test_e2e.py +0 -0
  81. {koatl-0.1.35 → koatl-0.1.36}/koatl/tests/test_parse.py +0 -0
  82. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/Cargo.toml +0 -0
  83. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/parser/Cargo.toml +0 -0
  84. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/parser/src/ast.rs +0 -0
  85. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/parser/src/lexer.rs +0 -0
  86. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/parser/src/lib.rs +0 -0
  87. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/parser/src/parser.rs +0 -0
  88. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/parser/src/util.rs +0 -0
  89. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/src/inference.rs +0 -0
  90. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/src/lib.rs +0 -0
  91. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/src/main.rs +0 -0
  92. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/src/parse_timer.rs +0 -0
  93. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/src/parser.rs +0 -0
  94. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/src/py/ast.rs +0 -0
  95. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/src/py/emit.rs +0 -0
  96. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/src/py/mod.rs +0 -0
  97. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/src/py/util.rs +0 -0
  98. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/src/types.rs +0 -0
  99. {koatl-0.1.35 → koatl-0.1.36}/koatl-core/src/util.rs +0 -0
  100. {koatl-0.1.35 → koatl-0.1.36}/pyproject.toml +0 -0
  101. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/__init__.py +0 -0
  102. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/__main__.py +0 -0
  103. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/cli.py +0 -0
  104. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/notebook/__init__.py +0 -0
  105. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/notebook/magic.py +0 -0
  106. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/prelude/__init__.tl +0 -0
  107. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/prelude/functional/__init__.tl +0 -0
  108. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/prelude/functional/algebra.tl +0 -0
  109. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/prelude/functional/async.tl +0 -0
  110. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/prelude/functional/env.tl +0 -0
  111. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/prelude/functional/list.tl +0 -0
  112. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/prelude/functional/memo.tl +0 -0
  113. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/prelude/functional/result.tl +0 -0
  114. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/prelude/io.tl +0 -0
  115. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/prelude/regex.tl +0 -0
  116. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/runtime/__init__.py +0 -0
  117. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/runtime/classes.py +0 -0
  118. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/runtime/helpers.py +0 -0
  119. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/runtime/meta_finder.py +0 -0
  120. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/runtime/record.py +0 -0
  121. {koatl-0.1.35 → koatl-0.1.36}/python/koatl/runtime/virtual.py +0 -0
@@ -99,7 +99,7 @@ checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd"
99
99
 
100
100
  [[package]]
101
101
  name = "koatl"
102
- version = "0.1.35"
102
+ version = "0.1.36"
103
103
  dependencies = [
104
104
  "ariadne",
105
105
  "koatl-core",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: koatl
3
- Version: 0.1.35
3
+ Version: 0.1.36
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "koatl"
3
- version = "0.1.35"
3
+ version = "0.1.36"
4
4
  edition = "2021"
5
5
 
6
6
  [lib]
@@ -11,6 +11,16 @@ export Iterable = Extension.trait& class(Traversable, Trait):
11
11
  next(it, None)
12
12
  it
13
13
 
14
+ skip_while = (self, f) =>
15
+ let it = self.iter
16
+ while True:
17
+ try:
18
+ let value = next(it)
19
+ if not f(value):
20
+ return Iterable.chain([value], it)
21
+ except StopIteration():
22
+ return it
23
+
14
24
  take = (self, n) =>
15
25
  let impl = () =>
16
26
  let it = self.iter
@@ -70,7 +80,7 @@ export Iterable = Extension.trait& class(Traversable, Trait):
70
80
 
71
81
  reverse = self => reversed(list(self.iter))
72
82
 
73
- sort = (self, key=None, reverse=False) =>
83
+ sorted = (self, key=None, reverse=False) =>
74
84
  sorted(self.iter, key=key, reverse=reverse)
75
85
 
76
86
  copy = self => itertools.tee(self.iter)
@@ -99,19 +109,19 @@ export Iterable = Extension.trait& class(Traversable, Trait):
99
109
  acc[i] = value
100
110
  acc
101
111
 
102
- group_by = (self, f) =>
112
+ group_by = (self, f=None) =>
103
113
  let acc = dict()
104
114
  for i in self:
105
- let key = f(i)
115
+ let key = f === None then i else f(i)
106
116
  if not acc.__contains__(key):
107
117
  acc[key] = []
108
118
  acc[key].append(i)
109
119
  acc
110
120
 
111
- count_by = (self, f) =>
121
+ count_by = (self, f=None) =>
112
122
  let acc = dict()
113
123
  for i in self:
114
- let key = f(i)
124
+ let key = f === None then i else f(i)
115
125
  if not acc.__contains__(key):
116
126
  acc[key] = 0
117
127
  acc[key] += 1
@@ -142,6 +142,10 @@ impl<'src> ResolveState<'src> {
142
142
  fn_ctx.captures.insert(found.decl.clone().into());
143
143
 
144
144
  for fn_ctx in self.fn_stack.iter_mut().rev().skip(1) {
145
+ if fn_ctx.decls.contains(&found.decl) {
146
+ break;
147
+ }
148
+
145
149
  fn_ctx.indirect_captures.insert(found.decl.clone().into());
146
150
  }
147
151
 
@@ -152,9 +156,12 @@ impl<'src> ResolveState<'src> {
152
156
 
153
157
  if lhs {
154
158
  if scope.is_class || scope.is_global {
155
- let decl =
156
- self.declarations
157
- .insert_declaration(ident.clone(), scope_key, DeclType::Let);
159
+ let decl = self.declarations.insert_declaration(
160
+ &mut self.fn_stack,
161
+ ident.clone(),
162
+ scope_key,
163
+ DeclType::Let,
164
+ );
158
165
 
159
166
  scope.locals.push(decl.clone());
160
167
 
@@ -163,9 +170,12 @@ impl<'src> ResolveState<'src> {
163
170
  }
164
171
 
165
172
  if !lhs {
166
- let decl =
167
- self.declarations
168
- .insert_declaration(ident.clone(), self.root_scope, DeclType::Let);
173
+ let decl = self.declarations.insert_declaration(
174
+ &mut self.fn_stack,
175
+ ident.clone(),
176
+ self.root_scope,
177
+ DeclType::Let,
178
+ );
169
179
 
170
180
  self.scopes[self.root_scope].locals.push(decl.clone());
171
181
 
@@ -212,6 +222,7 @@ impl<'src> ResolveState<'src> {
212
222
  let temp_scope_key = self.scopes.insert(dummy_scope);
213
223
 
214
224
  let ph_decl = self.declarations.insert_declaration(
225
+ &mut self.fn_stack,
215
226
  Ident("x".into()).spanned(span),
216
227
  temp_scope_key,
217
228
  DeclType::Let,
@@ -332,9 +343,9 @@ impl<'src> ResolveState<'src> {
332
343
 
333
344
  let key = *self.scope_stack.last().unwrap();
334
345
 
335
- let decl = self
336
- .declarations
337
- .insert_declaration(name.clone(), key, modifier);
346
+ let decl =
347
+ self.declarations
348
+ .insert_declaration(&mut self.fn_stack, name.clone(), key, modifier);
338
349
 
339
350
  if lifted {
340
351
  self.scopes[key].lifted_decls.push(decl.clone());
@@ -415,6 +426,8 @@ pub struct FnInfo {
415
426
  pub is_memo: bool,
416
427
  pub is_mapped_rhs: bool,
417
428
 
429
+ pub decls: Vec<DeclarationKey>,
430
+
418
431
  pub arg_names: Vec<DeclarationKey>,
419
432
 
420
433
  /**
@@ -439,6 +452,7 @@ impl FnInfo {
439
452
  is_memo: false,
440
453
  is_mapped_rhs: false,
441
454
  arg_names: Vec::new(),
455
+ decls: Vec::new(),
442
456
  captures: HashSet::new(),
443
457
  indirect_captures: HashSet::new(),
444
458
  }
@@ -461,6 +475,7 @@ pub struct Declaration<'src> {
461
475
  trait DeclSlotMapExt<'src> {
462
476
  fn insert_declaration(
463
477
  &mut self,
478
+ fn_stack: &mut Vec<FnInfo>,
464
479
  name: SIdent<'src>,
465
480
  scope: ScopeKey,
466
481
  modifier: DeclType,
@@ -470,6 +485,7 @@ trait DeclSlotMapExt<'src> {
470
485
  impl<'src> DeclSlotMapExt<'src> for SlotMap<DeclarationKey, Declaration<'src>> {
471
486
  fn insert_declaration(
472
487
  &mut self,
488
+ fn_stack: &mut Vec<FnInfo>,
473
489
  name: SIdent<'src>,
474
490
  scope: ScopeKey,
475
491
  modifier: DeclType,
@@ -486,7 +502,15 @@ impl<'src> DeclSlotMapExt<'src> for SlotMap<DeclarationKey, Declaration<'src>> {
486
502
  is_import: false,
487
503
  };
488
504
 
489
- self.insert(decl)
505
+ let key = self.insert(decl);
506
+
507
+ if let Some(fnctx) = fn_stack.last_mut() {
508
+ if matches!(modifier, DeclType::Let | DeclType::Const) {
509
+ fnctx.decls.push(key);
510
+ }
511
+ }
512
+
513
+ key
490
514
  }
491
515
  }
492
516
 
@@ -614,9 +638,12 @@ fn error_ident_and_decl<'src>(
614
638
  let ident = Ident("_".into()).spanned(span);
615
639
  let expr = Expr::Ident(ident.clone()).spanned(span).indirect();
616
640
 
617
- let decl = state
618
- .declarations
619
- .insert_declaration(ident.clone(), state.err_scope, DeclType::Let);
641
+ let decl = state.declarations.insert_declaration(
642
+ &mut state.fn_stack,
643
+ ident.clone(),
644
+ state.err_scope,
645
+ DeclType::Let,
646
+ );
620
647
 
621
648
  state.resolutions.insert(expr.as_ref().into(), decl);
622
649
 
@@ -861,6 +888,7 @@ fn pattern_scoped<'src>(
861
888
  .iter()
862
889
  .map(|x| {
863
890
  state.declarations.insert_declaration(
891
+ &mut state.fn_stack,
864
892
  x.clone().spanned(pattern.span),
865
893
  scope_key,
866
894
  DeclType::Let,
@@ -1187,6 +1215,7 @@ impl<'src> SExprExt<'src> for Indirect<SExpr<'src>> {
1187
1215
  let cap = capture.spanned(pattern.span);
1188
1216
 
1189
1217
  let decl = state.declarations.insert_declaration(
1218
+ &mut state.fn_stack,
1190
1219
  cap,
1191
1220
  scope,
1192
1221
  DeclType::Let,
@@ -1210,6 +1239,7 @@ impl<'src> SExprExt<'src> for Indirect<SExpr<'src>> {
1210
1239
  }
1211
1240
  ArgDefItem::ArgSpread(arg) => {
1212
1241
  let decl = state.declarations.insert_declaration(
1242
+ &mut state.fn_stack,
1213
1243
  arg.clone(),
1214
1244
  scope,
1215
1245
  DeclType::Let,
@@ -1221,6 +1251,7 @@ impl<'src> SExprExt<'src> for Indirect<SExpr<'src>> {
1221
1251
  }
1222
1252
  ArgDefItem::KwargSpread(arg) => {
1223
1253
  let decl = state.declarations.insert_declaration(
1254
+ &mut state.fn_stack,
1224
1255
  arg.clone(),
1225
1256
  scope,
1226
1257
  DeclType::Let,
@@ -1432,7 +1463,7 @@ impl<'src> SExprExt<'src> for Indirect<SExpr<'src>> {
1432
1463
  MappingItem::Item(key.traverse(state), value.traverse(state))
1433
1464
  }
1434
1465
  MappingItem::Spread(i) => MappingItem::Spread(i.traverse(state)),
1435
- MappingItem::Ident(i) => MappingItem::Ident(i),
1466
+ MappingItem::Ident(i) => MappingItem::Ident(i.traverse(state)),
1436
1467
  })
1437
1468
  .collect::<Vec<_>>(),
1438
1469
  ),
@@ -1640,6 +1671,7 @@ impl<'src> SStmtExt<'src> for Indirect<SStmt<'src>> {
1640
1671
  ImportList::Leaves(imports) => {
1641
1672
  for (ident, as_name) in imports {
1642
1673
  let decl = state.declarations.insert_declaration(
1674
+ &mut state.fn_stack,
1643
1675
  as_name.clone().unwrap_or(ident.clone()),
1644
1676
  scope_key,
1645
1677
  if import_stmt.reexport {
@@ -2019,9 +2019,10 @@ impl<'src, 'ast> SExprExt<'src, 'ast> for SExpr<'src> {
2019
2019
  for capture in deps_set {
2020
2020
  let decl = &ctx.declarations[*capture];
2021
2021
  let decl_scope = &ctx.scopes[decl.scope];
2022
+ let py_name = ctx.decl_py_ident(*capture)?;
2022
2023
 
2023
2024
  if !decl_scope.is_global {
2024
- nonglobal_deps.push(decl.name.0.clone());
2025
+ nonglobal_deps.push(py_name.clone());
2025
2026
  }
2026
2027
  }
2027
2028
 
@@ -11,6 +11,16 @@ export Iterable = Extension.trait& class(Traversable, Trait):
11
11
  next(it, None)
12
12
  it
13
13
 
14
+ skip_while = (self, f) =>
15
+ let it = self.iter
16
+ while True:
17
+ try:
18
+ let value = next(it)
19
+ if not f(value):
20
+ return Iterable.chain([value], it)
21
+ except StopIteration():
22
+ return it
23
+
14
24
  take = (self, n) =>
15
25
  let impl = () =>
16
26
  let it = self.iter
@@ -70,7 +80,7 @@ export Iterable = Extension.trait& class(Traversable, Trait):
70
80
 
71
81
  reverse = self => reversed(list(self.iter))
72
82
 
73
- sort = (self, key=None, reverse=False) =>
83
+ sorted = (self, key=None, reverse=False) =>
74
84
  sorted(self.iter, key=key, reverse=reverse)
75
85
 
76
86
  copy = self => itertools.tee(self.iter)
@@ -99,19 +109,19 @@ export Iterable = Extension.trait& class(Traversable, Trait):
99
109
  acc[i] = value
100
110
  acc
101
111
 
102
- group_by = (self, f) =>
112
+ group_by = (self, f=None) =>
103
113
  let acc = dict()
104
114
  for i in self:
105
- let key = f(i)
115
+ let key = f === None then i else f(i)
106
116
  if not acc.__contains__(key):
107
117
  acc[key] = []
108
118
  acc[key].append(i)
109
119
  acc
110
120
 
111
- count_by = (self, f) =>
121
+ count_by = (self, f=None) =>
112
122
  let acc = dict()
113
123
  for i in self:
114
- let key = f(i)
124
+ let key = f === None then i else f(i)
115
125
  if not acc.__contains__(key):
116
126
  acc[key] = 0
117
127
  acc[key] += 1
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes