-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes variable initialization of concept
types with ORC on Macos and Linux i386
#20380
Conversation
concept
types with ORC initialization
concept
types with ORC initializationconcept
types with ORC
89feef8
to
425cc30
Compare
if formal.kind == tyUserTypeClass: | ||
result.typ = arg.typ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't see where concept types are resolved to concrete types. When it seemed to be a tyConcept
type at the c code gen phase, not a string type. It causes difficulties for the ORC code generator, which initializes the string with a tyConcept
type using static const
which should have been a variable.
Please outline why this affects ORC. |
type
stringTest = concept x
x is string
let usedToFail: stringTest = "111"
echo usedToFail generates code like below
which is not accepted by some C compilers => my first commit verifies that (cd90ec7) which only test the specified test with ORC but it failed. Here is the CI https://github.com/nim-lang/Nim/runs/8413141986 It seems to be specific to macos with C backend and Linux i386, probably related to the C compiler. But still I suppose it should be a concrete type instead of a tyConcept type at code gen phase. |
Found it proc potentialValueInit(p: BProc; v: PSym; value: PNode): Rope =
if lfDynamicLib in v.loc.flags or sfThread in v.flags or p.hcrOn:
result = nil
elif sfGlobal in v.flags and value != nil and isDeepConstExpr(value, p.module.compileToCpp) and
p.withinLoop == 0 and not containsGarbageCollectedRef(v.typ):
#echo "New code produced for ", v.name.s, " ", p.config $ value.info
result = genBracedInit(p, value, isConst = false, v.typ)
else:
result = nil in of tyString, tyCstring:
if optSeqDestructors in p.config.globalOptions and n.kind != nkNilLit and ty == tyString:
result = genStringLiteralV2Const(p.module, n, isConst)
else:
var d: TLoc
initLocExpr(p, n, d)
result = rdLoc(d) The snippet above is picked up from the |
concept
types with ORC concept
types with ORC on Macos and Linux i386
Shouldn't we fix |
After |
ref #19972 (comment)
given a small test case
After matching the concept type and the type of argument using
paramTypesMatch
, we can infer the type ofusedToFail
withstring
instead of keeping usingtyConcept
type. We don't need to usetypeAllowed
to check whether the concept is properly constructed because it is checked at the concept definition.