Repository navigation
Description
Maybe it's a known (compiler) limitation but it seems that an inherited padded generic class with inline members will result compiler internal errors. Please note I already have a struct based field padding implementation - but I would like to also make this work with this object inheritance based padding mechanism. Unfortunately a single class and padding fields will not work, because the JIT free to reorder the fields within a clas but it will not reorder the fields across "inheritance borders".
The non-full example code looks like this:
[<NoEquality; NoComparison>]
[<Class>]
type PaddedReferenceRightPad<'T when 'T : not struct> =
inherit PaddedReferenceBase<'T>
val mutable Right: PaddedReferenceRightPadding
new() = { inherit PaddedReferenceBase<'T>(); Right = PaddedReferenceRightPadding() }
new(v: 'T) = { inherit PaddedReferenceBase<'T>(v); Right = PaddedReferenceRightPadding() }
[<NoEquality; NoComparison>]
[<Class>]
type PaddedReference<'T when 'T : not struct> =
inherit PaddedReferenceRightPad<'T>
new(value) = { inherit PaddedReferenceRightPad<'T>(value) }
member inline x.Read() =
GenericOperations.read x.Value
member inline x.ReadByRef() =
GenericOperations.readByRef &x.ValueThe full example code are available here:
https://gist.github.com/zpodlovics/aa333619a39facdeba90
Compilation will result the following errors
/tmp/fsharpgenericpaddedinlinemember.fs(84,21): error FS0073: internal error: the mustinline value 'Read' was not inferred to have a known value
/tmp/fsharpgenericpaddedinlinemember.fs(87,21): error FS0073: internal error: the mustinline value 'ReadByRef' was not inferred to have a known value
/tmp/fsharpgenericpaddedinlinemember.fs(84,21): error FS1113: The value 'Read' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible
/tmp/fsharpgenericpaddedinlinemember.fs(87,21): error FS1113: The value 'ReadByRef' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible
/tmp/fsharpgenericpaddedinlinemember.fs(84,21): error FS0073: internal error: the mustinline value 'Read' was not inferred to have a known value
/tmp/fsharpgenericpaddedinlinemember.fs(87,21): error FS0073: internal error: the mustinline value 'ReadByRef' was not inferred to have a known value
/tmp/fsharpgenericpaddedinlinemember.fs(84,21): error FS1113: The value 'Read' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible
/tmp/fsharpgenericpaddedinlinemember.fs(87,21): error FS1113: The value 'ReadByRef' was marked inline but its implementation makes use of an internal or private function which is not sufficiently accessible
Is there any workaround available to use this object inheritance based padding mechanism?
Thanks for your help,
Zoltan
Activity
abelbraaksma commentedon Nov 26, 2015
Note, for one of those errors, the error:
you do not need to have a padded, or even generic class, it simply happens "always", as soon as you inherit a class and it has any inline method in the derived class. I reported that earlier here, and there's a StackOverflow question that shows this bug has been around since F# 2.0.
mpetruska commentedon Dec 23, 2015
Started to investigate this bug, here's my current progress:
inherit Base<'T>()the module is compiled successfully.Infofield toUnknownValue, which will cause the IsPartialExprVal function to return true.mpetruska commentedon Dec 23, 2015
I think PR #763 contains the fix for this bug.
abelbraaksma commentedon Dec 23, 2015
Have you also seen #763? It contains a fix for my later bug #740, which I think is the same issue (though I'm not 100% sure). Would be a pity if you'd be doing the work twice... ;)
abelbraaksma commentedon Dec 23, 2015
Oops, sorry, should've refreshed my window... you found it already ;)
mpetruska commentedon Dec 23, 2015
Hi, tested the changes in PR #763 on .Net 4.5, it seems that it solves this issue (both the original and the simplified code) compilation succeeds.
abelbraaksma commentedon Dec 24, 2015
Glad to hear it fixes the issue! The PR is in need of test cases, I haven't gotten around to looking into it yet (I'm not that accustomed to the whole process flow yet), but if you have test cases and you want to / can add them for #763, please do.
eriawan commentedon Dec 24, 2015
@KevinRansom ,
Just FYI, if this issue is fixed, (according to previous conversations) we should close this issue. I also think this issue doesn't need to be tracked anymore.
cc @dsyme