diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 0196b9d03c..336c80c20c 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -823,9 +823,11 @@ proc semConst(c: PContext, n: PNode): PNode = addToVarSection(c, result, b) continue + var hasUserSpecifiedType = false var typ: PType = nil if a[^2].kind != nkEmpty: typ = semTypeNode(c, a[^2], nil) + hasUserSpecifiedType = true var typFlags: TTypeAllowedFlags = {} @@ -866,6 +868,8 @@ proc semConst(c: PContext, n: PNode): PNode = else: for j in 0.. 0: @@ -581,8 +585,11 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string = if not isIntLit(t) or prefer == preferExported: result = typeToStr[t.kind] else: - if prefer == preferGenericArg: + case prefer: + of preferGenericArg: result = $t.n.intVal + of preferInlayHint: + result = "int" else: result = "int literal(" & $t.n.intVal & ")" of tyGenericInst, tyGenericInvocation: diff --git a/nimsuggest/nimsuggest.nim b/nimsuggest/nimsuggest.nim index 3834acb93c..21baf131e5 100644 --- a/nimsuggest/nimsuggest.nim +++ b/nimsuggest/nimsuggest.nim @@ -1115,7 +1115,7 @@ proc executeNoHooksV3(cmd: IdeCmd, file: AbsoluteFile, dirtyfile: AbsoluteFile, i += parseInt(tag, endCol, i) let s = graph.findSymDataInRange(file, line, col, endLine, endCol) for q in s: - if q.sym.kind in {skLet, skVar, skForVar} and q.isDecl and not q.sym.hasUserSpecifiedType: + if q.sym.kind in {skLet, skVar, skForVar, skConst} and q.isDecl and not q.sym.hasUserSpecifiedType: graph.suggestInlayHintResult(q.sym, q.info, ideInlayHints) else: myLog fmt "Discarding {cmd}"