[Feature request] Add cast function with sugared syntax
还没有人认领这个 Issue。
评估
调研方向
该 issue 描述了一个新的 cast(mixed, classtype) 函数和带语法糖的 (type) 表达式语法,包括 ClassCastException 的行为以及一个类型检查示例。由于没有指定源文件、测试或入口点,请先定位现有的 integer、string、boolean 和 double 转换,以及表达式的 parser 和类型检查路径。完成的标准是两种形式都能转换为请求的类型,并按指定拒绝不兼容的值。
由索引模型根据 Issue 内容生成。
描述
Problem
MethodScript currently does not have a method to cast to any desired type. This makes it impossible to fully statically type programs such as:
mixed @a = ...;
if(@a instanceof array) {
array @arr = @a; // Typecheck error, need to insert a cast.
}
Proposed solution
- Add a
cast(mixed, classtype)function that casts the given mixed to the given classtype, or throws aClassCastExceptionwhen it can't. - Add
(type) expressionsyntax that compiles tocast(expression, type).
Note that MethodScript currently does have integer(mixed), string(mixed), boolean(mixed) and double(mixed) that all cast to one specific type.
- 主要语言
- Java
- 星标
- 128
- 派生
- 70
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
EngineHub/CommandHelper 的其他 Issue
-
discussion wanted documentation
难度 5/5 一周以上 新手友好度 25/100
EngineHub/CommandHelper#1403 ·
-
难度 5/5 一周以上 新手友好度 25/100
EngineHub/CommandHelper#1370 · 1 条评论 ·
-
bug
难度 4/5 3-5 天 新手友好度 35/100
EngineHub/CommandHelper#1354 ·
-
bug
难度 4/5 3-5 天 新手友好度 45/100
EngineHub/CommandHelper#1349 · 3 条评论 ·
-
bug
难度 5/5 一周以上 新手友好度 25/100
EngineHub/CommandHelper#1341 · 2 条评论 ·
查看 EngineHub/CommandHelper 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
ci-failure-cause test-failure
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 65/100
nextcloud/notes-android#3367 ·
维护者通常 1 天内回复
-
:wave: team-triage a:chore in:isolated-projects in:kotlin-dsl
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复