Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit71a3609

Browse files
libozKevinRansom
authored andcommitted
* attempt to fix units of measure issue with structs and no optimizations* reducing code duplication* keep the original comment* add test
1 parent6726231 commit71a3609

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

‎src/fsharp/IlxGen.fs‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5362,11 +5362,15 @@ and GenBindRhs cenv cgbuf eenv sp (vspec:Val) e =
53625362
| Expr.TyLambda_| Expr.Lambda_->
53635363
letisLocalTypeFunc= IsNamedLocalTypeFuncVal cenv.g vspec e
53645364

5365-
match e, isLocalTypeFuncwith
5366-
| Expr.TyLambda(_, tyargs, body,_,_),truewhen
5365+
match ewith
5366+
| Expr.TyLambda(_, tyargs, body,_,ttype)when
53675367
(
53685368
tyargs|> List.forall(fun tp-> tp.IsErased)&&
5369-
(match StorageForVal vspec.Range vspec eenvwith Local_->true|_->false)
5369+
(match StorageForVal vspec.Range vspec eenvwith Local_->true|_->false)&&
5370+
(isLocalTypeFunc||
5371+
(match ttypewith
5372+
TType_var(typar)->match typar.Solutionwith Some(TType_app(t,_))-> t.IsStructOrEnumTycon|_->false
5373+
|_->false))
53705374
)->
53715375
// type lambda with erased type arguments that is stored as local variable (not method or property)- inline body
53725376
GenExpr cenv cgbuf eenv sp body Continue
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
typeAStruct<[<Measure>]'u>=
2+
struct
3+
end
4+
5+
[<EntryPoint>]
6+
letmain argv=
7+
letx= AStruct()// This doesn't work
8+
0

‎tests/fsharp/tests.fs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,14 @@ module RegressionTests =
14391439
[<Test >]
14401440
let``struct-tuple-bug-1-FSI_BASIC``()= singleTestBuildAndRun"regression/struct-tuple-bug-1" FSI_BASIC
14411441

1442+
[<Test>]
1443+
let``struct-measure-bug-1``()=
1444+
letcfg= testConfig"regression/struct-measure-bug-1"
1445+
1446+
fsc cfg"%s --optimize- -o:test.exe -g" cfg.fsc_flags["test.fs"]
1447+
1448+
peverify cfg"test.exe"
1449+
14421450
#if!FSHARP_SUITE_DRIVES_CORECLR_TESTS
14431451
moduleOptimizationTests=
14441452

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp