From 9979d68202fceeda3e9342f15ad47e79e1bae336 Mon Sep 17 00:00:00 2001 From: Grigory Buteyko Date: Thu, 12 Dec 2024 02:59:38 +0300 Subject: [PATCH] fixes to new linting to pass combined.tl --- cmd/tlgen/main2.go | 13 ++++++++++--- internal/tlcodegen/tlgen.go | 11 +++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/cmd/tlgen/main2.go b/cmd/tlgen/main2.go index 8b93dd1..2687ddb 100644 --- a/cmd/tlgen/main2.go +++ b/cmd/tlgen/main2.go @@ -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 } @@ -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 { diff --git a/internal/tlcodegen/tlgen.go b/internal/tlcodegen/tlgen.go index 67bd2e8..3dcce2f 100644 --- a/internal/tlcodegen/tlgen.go +++ b/internal/tlcodegen/tlgen.go @@ -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()))