Skip to content

Commit 4747ec3

Browse files
committed
Fixes
1 parent ba44115 commit 4747ec3

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

tools/FileRefExtractor/BuildMode/Ast.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,31 +90,44 @@ public function addNode(TLContext $ctx, ?array $action = null, ?string $why = nu
9090
$constructor = $action['stored_constructor'];
9191

9292
$names = $this->storedNames;
93+
$flags = [];
9394
if ($this->storedFlags) {
95+
foreach ($names as $name => $type) {
96+
if (str_starts_with($type, 'flags.')) {
97+
$flags[$name] = $type;
98+
}
99+
}
94100
$names = [
95101
'flags' => '#',
96102
...$names
97103
];
98104
}
99105

100106
if (isset($this->outputSchema[$constructor])) {
101-
foreach ($this->outputSchema[$constructor] as $name => $type) {
107+
$existing = $this->outputSchema[$constructor];
108+
foreach ($existing as $name => $type) {
109+
if (str_starts_with($type, 'flags.')) {
110+
if (isset($flags[$name])) {
111+
unset($flags[$name], $names[$name]);
112+
}
113+
}
114+
}
115+
if ($flags) {
116+
throw new AssertionError("Have leftover flags: ".implode(' ', $flags));
117+
}
118+
foreach ($existing as $name => $type) {
102119
if (isset($names[$name])) {
103120
if ($names[$name] === $type) {
104121
unset($names[$name]);
105122
} else {
106123
throw new AssertionError("Type mismatch for $constructor.$name: have {$names[$name]}, need $type");
107124
}
108-
} else if (str_starts_with($type, 'flags.')) {
109-
if ($this->storedFlags) {
110-
throw new AssertionError("Have conflicting flag $constructor.$name:$type; new schema is ".self::stringifySchema($constructor, $names));
111-
}
112-
} elseif ($name !== 'flags') {
125+
} elseif (!str_starts_with($type, 'flags.') && $name !== 'flags') {
113126
throw new AssertionError("Missing pre-existing parameter $constructor.$name for $constructor");
114127
}
115128
}
116129
foreach ($names as $name => $type) {
117-
throw new AssertionError("Leftover parameter $constructor.$name:$type for $constructor");
130+
throw new AssertionError("Leftover parameter $constructor.$name:$type for ".self::stringifySchema($constructor, $existing));
118131
}
119132
} else {
120133
$this->outputSchema[$constructor] = $names;

tools/gen_filerefmap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,10 @@
503503
],
504504
'fileSourceStarsTransaction' => [
505505
'flags' => '#',
506+
'peer' => 'InputPeer',
506507
'id' => 'string',
507508
'refund' => 'flags.0?true',
509+
'ton' => 'flags.1?true',
508510
]
509511
];
510512

0 commit comments

Comments
 (0)