Skip to content

Commit

Permalink
fixes to new linting to pass combined.tl
Browse files Browse the repository at this point in the history
  • Loading branch information
hrissan committed Dec 11, 2024
1 parent 9f7f6d6 commit 9979d68
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
13 changes: 10 additions & 3 deletions cmd/tlgen/main2.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ func runMain(opt *tlcodegen.Gen2Options) error {
return fmt.Errorf("error while walkking through paths: %w", err)
}
for _, path := range paths {
tl, err := parseTlFile(path, false, opt)
tl, err := parseTlFile(path, true, opt)
if err != nil {
return err
}
fullTl, err := parseTlFile(path, true, opt)
fullTl, err := parseTlFile(path, false, opt)
if err != nil {
return err
}
Expand Down Expand Up @@ -197,10 +197,17 @@ func parseTlFile(file string, replaceStrange bool, opt *tlcodegen.Gen2Options) (
dataStr = strings.ReplaceAll(dataStr, "_ {X:Type} result:X = ReqResult X;", "")
dataStr = strings.ReplaceAll(dataStr, "engine.query {X:Type} query:!X = engine.Query;", "")
dataStr = strings.ReplaceAll(dataStr, "engine.queryShortened query:%(VectorTotal int) = engine.Query;", "")
// dataStr = strings.ReplaceAll(dataStr, "engine.queryShortened query:%(VectorTotal int) = engine.Query;", "")
// dataStr = strings.ReplaceAll(dataStr, "@any @internal engine.sendResponseTo {X:Type} pid:%net.Pid query:!X = Bool;", "")
// dataStr = strings.ReplaceAll(dataStr, "@internal @write messages.responseQuery {X:Type} response_query_id:long query:!X = X;", "")
// dataStr = strings.ReplaceAll(dataStr, "@any rpcDestActor#7568aabd {X:Type} actor_id:long query:!X = X;", "")
// dataStr = strings.ReplaceAll(dataStr, "@any rpcDestActorFlags#f0a5acf7 {X:Type} actor_id:long flags:# extra:%(RpcInvokeReqExtra flags) query:!X = X;", "")
// dataStr = strings.ReplaceAll(dataStr, "@any rpcDestFlags#e352035e {X:Type} flags:# extra:%(RpcInvokeReqExtra flags) query:!X = X;", "")
// dataStr = strings.ReplaceAll(dataStr, "@any rpcInvokeReq#2374df3d {X:Type} query_id:long query:!X = RpcReqResult X;", "")
}
tl, err := tlast.ParseTLFile(dataStr, file, tlast.LexerOptions{
AllowBuiltin: false,
AllowDirty: false,
AllowDirty: !replaceStrange,
AllowMLC: !opt.WarningsAreErrors,
}, opt.ErrorWriter)
if err != nil {
Expand Down
11 changes: 7 additions & 4 deletions internal/tlcodegen/tlgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,13 @@ func (gen *Gen2) buildMapDescriptors(tl tlast.TL) error {
gen.typeDescriptors[typeName] = append(gen.typeDescriptors[typeName], typ)
}
} else {
if len(typ.TemplateArguments) != 0 {
// @read funWithArg {fields_mask: #} => True;
pr := typ.TemplateArgumentsPR
return pr.BeautifulError(fmt.Errorf("function declaration %q cannot have template arguments", conName))
for _, t := range typ.TemplateArguments {
if t.IsNat {
// @read funWithArg {fields_mask: #} => True;
return t.PR.BeautifulError(fmt.Errorf("function declaration %q cannot have template arguments", conName))
}
// TODO - sort out things with rpc wrapping later which has a form
// @readwrite tree_stats.preferMaster {X:Type} query:!X = X;
}
if len(typ.Modifiers) == 0 && doLint(typ.CommentRight) {
e1 := typ.Construct.NamePR.CollapseToBegin().BeautifulError(fmt.Errorf("function constructor %q without modifier (identifier starting with '@') not recommended", typ.Construct.Name.String()))
Expand Down

0 comments on commit 9979d68

Please sign in to comment.