Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
dotNET Platform
fsharp
提交
d9695e1b
F
fsharp
项目概览
dotNET Platform
/
fsharp
12 个月 前同步成功
通知
0
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
fsharp
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d9695e1b
编写于
3月 30, 2020
作者:
K
Kevin Ransom (msft)
提交者:
GitHub
3月 30, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix
https://github.com/dotnet/fsharp/issues/8802
(#8827)
上级
47984465
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
50 addition
and
14 deletion
+50
-14
src/fsharp/lex.fsl
src/fsharp/lex.fsl
+15
-7
tests/fsharp/Compiler/Conformance/BasicGrammarElements/BasicConstants.fs
...mpiler/Conformance/BasicGrammarElements/BasicConstants.fs
+35
-7
未找到文件。
src/fsharp/lex.fsl
浏览文件 @
d9695e1b
...
...
@@ -159,6 +159,12 @@ let evalIfDefExpression startPos isFeatureSupported args (lookup:string->bool) (
let expr = FSharp.Compiler.PPParser.start tokenStream lexbuf
LexerIfdefEval lookup expr
let evalFloat args lexbuf =
try
float32(removeUnderscores (lexemeTrimRight lexbuf 1))
with _ ->
fail args lexbuf (FSComp.SR.lexInvalidFloat()) 0.0f
}
let letter = '\Lu' | '\Ll' | '\Lt' | '\Lm' | '\Lo' | '\Nl'
...
...
@@ -234,7 +240,9 @@ let bignum = integer ('I' | 'N' | 'Z' | 'Q' | 'R' | 'G')
let ieee64 = float
let ieee32 = (float | integer) ('f' | 'F')
let ieee32 = float ('f' | 'F')
let ieee32_dotless_no_exponent = integer ('f' | 'F')
let decimal = (float | integer) ('m' | 'M')
...
...
@@ -407,16 +415,16 @@ rule token args skip = parse
with _ -> fail args lexbuf (FSComp.SR.lexOutsideNativeUnsigned()) (UNATIVEINT(0UL)) }
| ieee32
{
let s = lexemeTrimRight lexbuf 1
if lexbuf.SupportsFeature LanguageFeature.DotlessFloat32Literal || s.Contains "." then
try
IEEE32 (float32 (removeUnderscores s))
with _ -> fail args lexbuf (FSComp.SR.lexInvalidFloat()) (IEEE32 0.0
f)
{
IEEE32 (evalFloat args lexbuf) }
| ieee32_dotless_no_exponent
{ if lexbuf.SupportsFeature LanguageFeature.DotlessFloat32Literal then
IEEE32 (evalFloat args lexbu
f)
else
fail args lexbuf (FSComp.SR.lexInvalidFloat()) (IEEE32 0.0f)
}
| ieee64
| ieee64
{ IEEE64 (try float(lexeme lexbuf) with _ -> fail args lexbuf (FSComp.SR.lexInvalidFloat()) 0.0) }
| decimal
...
...
tests/fsharp/Compiler/Conformance/BasicGrammarElements/BasicConstants.fs
浏览文件 @
d9695e1b
...
...
@@ -175,24 +175,52 @@ if x14 <> 0o52 then failwith "Wrong parsing"
printfn "
%
A
" x14
"""
[<
Test
>]
let
``
float without do
t``
()
=
let
``
dotless floa
t``
()
=
CompilerAssert
.
CompileExeWithOptions
[|
"--langversion:preview"
|]
"""
let x = 42f
printfn "
%
A
" x
"""
[<
Test
>]
let
``
float with do
t``
()
=
CompilerAssert
.
CompileExe
WithOptions
[|
"--langversion:preview"
|]
let
``
dotted floa
t``
()
=
CompilerAssert
.
CompileExe
"""
let x = 42.f
printfn "
%
A
" x
"""
[<
Test
>]
let
``dotted floats should be equal to dotless floats``
()
=
CompilerAssert
.
CompileExeAndRunWithOptions
[|
"--langversion:preview"
|]
"""
if 1.0f <> 1f then failwith "
1
.
0
f
<>
1
f
"
"""
[<
Test
>]
let
``exponent dotted floats should be equal to dotted floats``
()
=
CompilerAssert
.
CompileExeAndRun
"""
if 1.0e1f <> 10.f then failwith "
1.0e1
f
<>
10
.
f
"
"""
[<
Test
>]
let
``exponent dotless floats should be equal to dotted floats``
()
=
CompilerAssert
.
CompileExeAndRun
"""
if 1e1f <> 10.f then failwith "
1e1
f
<>
10
.
f
"
"""
[<
Test
>]
let
``exponent dotted floats should be equal to dotless floats``
()
=
CompilerAssert
.
CompileExeAndRunWithOptions
[|
"--langversion:preview"
|]
"""
if 1.0e1f <> 10f then failwith "
1.0e1
f
<>
10
f
"
"""
[<
Test
>]
let
``
floats with dot should be equal to floats without dot
``
()
=
let
``
exponent dotless floats should be equal to dotless floats
``
()
=
CompilerAssert
.
CompileExeAndRunWithOptions
[|
"--langversion:preview"
|]
"""
if 1
.0f <> 1f then failwith "
1
.
0
f
is
not
equal
to
1
f
"
if 1
e1f <> 10f then failwith "
1e1
f
<>
10
f
"
"""
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录