Skip to content
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

When DU is not at at the end of the code, FSharpChecker.ParseAndCheckProject failed. #6

Open
Tracked by #4
SilkyFowl opened this issue Jun 17, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@SilkyFowl
Copy link
Owner

SilkyFowl commented Jun 17, 2022

Work

// Some code...

type AnyDuHasNoValueLabelCase =
    | Foo
    | Bar of int

Not Work(Error Message: typecheck error Duplicate definition of type, exception or module 'Counter)

// Some code...
// So far, I can analyze it correctly.

type AnyDuHasNoValueLabelCase =
    | Foo
    | Bar of int

// Other some code...
// Not work

Test Code is here.

let module_with_some_value_after_DU =
let baseCode =
sprintf """
open System
open Avalonia.FuncUI
open Avalonia.FuncUI.DSL
open Avalonia.Controls
open Avalonia.FuncUI.LiveView.Core.Types
%s
module Counter =
open Avalonia.FuncUI
open Avalonia.Controls
open Avalonia.Media
open Avalonia.FuncUI.DSL
open Avalonia.Layout
let view =
Component.create (
"Counter",
fun ctx ->
let state = ctx.useState 0
Grid.create [
Grid.rowDefinitions "test,Auto"
Grid.children [
TextBlock.create [
TextBlock.text "Foo!!"
]
]
]
)
[<LivePreview>]
let preview () =
view
[<LivePreview>]
let preview2 =
let n = 1
view
"""
anyNoValueCaseDUs
|> List.map ( fun du ->
[| (baseCode >> box) du |]
)
let nestedAnyNoValueCaseDUs =
[
"""
type Foo = Foo
"""
"""
type Bar =
| Hoge
| Fuga of string
"""
"""
type Bar<'t> =
| Hoge
| Fuga of string
| A of {|a:int; b:string; c: bool * string|}
| B of ('t -> unit)
"""
]
let module_after_DU_contain_module =
let baseCode =
sprintf """
open System
open Avalonia.FuncUI
open Avalonia.FuncUI.DSL
open Avalonia.Controls
open Avalonia.FuncUI.LiveView.Core.Types
module DUs =
%s
module Counter =
open Avalonia.FuncUI
open Avalonia.Controls
open Avalonia.Media
open Avalonia.FuncUI.DSL
open Avalonia.Layout
let view =
Component.create (
"Counter",
fun ctx ->
let state = ctx.useState 0
Grid.create [
Grid.rowDefinitions "test,Auto"
Grid.children [
TextBlock.create [
TextBlock.text "Foo!!"
]
]
]
)
[<LivePreview>]
let preview () =
view
[<LivePreview>]
let preview2 =
let n = 1
view
"""
nestedAnyNoValueCaseDUs
|> List.map ( fun du ->
[| (baseCode >> box) du |]
)
[<Theory>]
[<MemberData(nameof module_with_some_value_after_DU)>]
[<MemberData(nameof module_after_DU_contain_module)>]
let ``wont work If module with some value after DU`` code =
let ex =
Assert.Throws<Sdk.EmptyException>(fun _ ->
createTestCode code
|> Helper.runFuncUIAnalysis
|> ignore
)
ex.Message |> shouldContainText "typecheck error Duplicate definition of type, exception or module 'Counter'"

Originally posted by @SilkyFowl in #1 (comment)

@SilkyFowl SilkyFowl added the bug Something isn't working label Jun 17, 2022
@SilkyFowl SilkyFowl mentioned this issue Jun 17, 2022
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant