gpt4 book ai didi

scala - 是什么导致此 Scala 错误消息?

转载 作者:行者123 更新时间:2023-12-04 12:22:06 24 4
gpt4 key购买 nike

我似乎找到了一条奇怪的错误消息的方法。我正在存储密码,我有一条评论说

/** A password hash is stored as `"algorithm$iterations$salt$hash"`
* with the number of iterations optional for some algorithms

当我尝试为我的项目创建一个分发 jar 时,我收到了这个警告:
Variable iterations undefined in comment for...

我将警告追溯到特征 package scala.tools.nsc.ast.DocComments ,我发现显然可以在 ScalaDoc 中放入某种变量。不幸的是,谷歌搜索“Scaladoc 中的变量”或“ScalaDoc 美元符号”并没有返回任何有用的信息。

有谁知道我错误地使用了什么功能以及如何包含美元符号
在 ScalaDoc 评论中没有收到警告?

最佳答案

作为猜测,我会从“$$”开始。然后我会尝试反斜杠来逃避它,这就是答案。

标准库充满了这些宏。 (例如,在 immutable.MapLike 中,

 *  @define Coll immutable.Map

用途 $Coll ,对于继承的文档。)

你会想 StringInterpolator将展示如何包括一美元。
 [scaladoc] /localhome/jenkins/a/workspace/pr-checkin-per-commit/src/library/scala/StringContext.scala:17: warning: Variable name undefined in comment for class StringContext in class StringContext
[scaladoc] * println(s"Hello, $name") // Hello, James
[scaladoc] ^
[scaladoc] /localhome/jenkins/a/workspace/pr-checkin-per-commit/src/library/scala/StringContext.scala:23: warning: Variable name undefined in comment for class StringContext in class StringContext
[scaladoc] * s"Hello, $name"
[scaladoc] ^
[scaladoc] /localhome/jenkins/a/workspace/pr-checkin-per-commit/src/library/scala/StringContext.scala:41: warning: Variable a undefined in comment for class StringContext in class StringContext
[scaladoc] * val x: JSONObject = json"{ a: $a }"
[scaladoc] ^

这是来自 sample sanity build for pull requests .

所有这些错误都来自类文档,而不是成员文档,所以这可能是一个提示;或者它可能只是在那个时候停止提示。

该工具在其输出中发出了精彩的引物,但不是针对您的问题:
 [scaladoc] Quick crash course on using Scaladoc links
[scaladoc] ==========================================
[scaladoc] Disambiguating terms and types: Prefix terms with '$' and types with '!' in case both names are in use:
[scaladoc] - [[scala.collection.immutable.List!.apply class List's apply method]] and
[scaladoc] - [[scala.collection.immutable.List$.apply object List's apply method]]
[scaladoc] Disambiguating overloaded members: If a term is overloaded, you can indicate the first part of its signature followed by *:
[scaladoc] - [[[scala.collection.immutable.List$.fill[A](Int)(⇒A):List[A]* Fill with a single parameter]]]
[scaladoc] - [[[scala.collection.immutable.List$.fill[A](Int,Int)(⇒A):List[List[A]]* Fill with a two parameters]]]
[scaladoc] Notes:
[scaladoc] - you can use any number of matching square brackets to avoid interference with the signature
[scaladoc] - you can use \\. to escape dots in prefixes (don't forget to use * at the end to match the signature!)
[scaladoc] - you can use \\# to escape hashes, otherwise they will be considered as delimiters, like dots.

更新 1:猜猜看,这个猜测似乎有效。它不再提示 $ROOT在这个输出中:
docs.partest:
[scaladoc] Documenting 33 source files to /home/apm/projects/snytt/build/scaladoc/partest
[scaladoc] model contains 110 documentable templates
[scaladoc] /home/apm/projects/snytt/src/partest/scala/tools/partest/BytecodeTest.scala:14: warning: Variable TESTDIR undefined in comment for class BytecodeTest in class BytecodeTest
[scaladoc] * 1. Create subdirectory in test/files/jvm for your test. Let's name it $TESTDIR.
[scaladoc] ^
[scaladoc] /home/apm/projects/snytt/src/partest/scala/tools/partest/BytecodeTest.scala:15: warning: Variable TESTDIR undefined in comment for class BytecodeTest in class BytecodeTest
[scaladoc] * 2. Create $TESTDIR/BytecodeSrc_1.scala that contains Scala source file that you
[scaladoc] ^
[scaladoc] /home/apm/projects/snytt/src/partest/scala/tools/partest/BytecodeTest.scala:18: warning: Variable TESTDIR undefined in comment for class BytecodeTest in class BytecodeTest
[scaladoc] * 3. Create $TESTDIR/Test.scala:
[scaladoc] ^
[scaladoc] Document succeeded with 3 warnings; see the documenter output for details.
[scaladoc] three warnings found
[stopwatch] [docs.partest.timer: 19.486 sec]

现在我去找 $TESTDIR .

哇,这真的很给力。感谢提问!

首先让我去检查 scaladoc 是否真的包含 $ROOT word 在其 html 输出中。

更新 2:你知道吗?只是别介意。结果是这样的,哈:
 A string that looks like a file path is normalized by replacing the leading segments (the root) with "$$ROOT"

更新 3:实际上, \$反斜杠转义工作正常。实际屏幕实时输出:
with "$ROOT" 

关于scala - 是什么导致此 Scala 错误消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18178801/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com