-
Notifications
You must be signed in to change notification settings - Fork 854
Open
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingArea-Compiler-Checking-NameResolutionModule/type name collisions, open behavior, shadowing, global namespaceModule/type name collisions, open behavior, shadowing, global namespaceBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone
Description
Values with [<Literal>] defined in recursive modules can not be used in contexts where a [<Literal>] is required.
The following examples compile fine:
module NonRecursive
let [<Literal>] x = ""
let [<Literal>] y = xmodule NonRecursive
type MyAttribute(x: string) =
inherit System.Attribute()
let [<Literal>] x = ""
let [<MyAttribute(x)>] y = ""module rec Recursive
let [<Literal>] x = ""
let y = x // literal not required, works fine even in recursive modulemodule NonRecursive
let [<Literal>] x = ""
module rec Recursive =
let [<Literal>] y = xThe following examples do not compile:
module rec Recursive
let [<Literal>] x = ""
let [<Literal>] y = x
// ^ The value or constructor 'x' is not defined
// ^ This is not a valid constant expression or custom attribute valuemodule rec Recursive
type MyAttribute(x: string) =
inherit System.Attribute()
let [<Literal>] x = ""
let [<MyAttribute(x)>] y = ""
// ^ The value or constructor 'x' is not defined
// ^ This is not a valid constant expression or custom attribute valuemodule rec Recursive =
let [<Literal>] x = ""
module NonRecursive =
let [<Literal>] y = x
// ^ The value or constructor 'x' is not defined
// ^ This is not a valid constant expression or custom attribute valueKnown workarounds
Define literals outside recursive modules (may be infeasible in some cases).
Related information
May be related to #5227.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingArea-Compiler-Checking-NameResolutionModule/type name collisions, open behavior, shadowing, global namespaceModule/type name collisions, open behavior, shadowing, global namespaceBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Type
Projects
Status
New