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

[Fable 5] Source maps generation is broken #3980

Open
MangelMaxime opened this issue Dec 17, 2024 · 2 comments
Open

[Fable 5] Source maps generation is broken #3980

MangelMaxime opened this issue Dec 17, 2024 · 2 comments
Labels

Comments

@MangelMaxime
Copy link
Member

MangelMaxime commented Dec 17, 2024

Description

It seems like we are missing information about the original file file and the source., which cause Fable 5 to break if --sourceMaps is provided.

To me it looks like the last blocking bug we need to fix to release Fable 5. Other things like full support for F# 9 feature can be done over time.

./../quicktest/QuickTest.fs(1,1): error EXCEPTION: Invalid mapping: { generated = { line = 54
                column = 85 }
  name = None
  original = Some { line = 0
                    column = 0 }
  source = Some "unknown" }
   at SourceMapSharp.SourceMapGenerator.ValidateMapping(MappingIndex generated, FSharpOption`1 original, FSharpOption`1 source, FSharpOption`1 name)
   at SourceMapSharp.SourceMapGenerator.AddMapping(MappingIndex generated, FSharpOption`1 original, FSharpOption`1 source, FSharpOption`1 name)
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCallExpression(Printer printer, Expression callee, Expression[] args, TypeAnnotation[] typeArguments, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1231
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArrowFunctionExpression(Printer printer, Parameter[] parameters, BlockStatement body, FSharpOption`1 returnType, TypeParameter[] typeParameters, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1041
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer-PrintCommaSeparatedArray@229-10.Invoke(Printer p, Expression x) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArray[a](Printer printer, a[] items, FSharpFunc`2 print, FSharpFunc`2 printSeparator) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 135
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCommaSeparatedArray(Printer printer, Expression[] items) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCallExpression(Printer printer, Expression callee, Expression[] args, TypeAnnotation[] typeArguments, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1235
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer-PrintCommaSeparatedArray@229-10.Invoke(Printer p, Expression x) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArray[a](Printer printer, a[] items, FSharpFunc`2 print, FSharpFunc`2 printSeparator) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 135
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCommaSeparatedArray(Printer printer, Expression[] items) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCallExpression(Printer printer, Expression callee, Expression[] args, TypeAnnotation[] typeArguments, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1235
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArrowFunctionExpression(Printer printer, Parameter[] parameters, BlockStatement body, FSharpOption`1 returnType, TypeParameter[] typeParameters, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1041
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer-PrintCommaSeparatedArray@229-10.Invoke(Printer p, Expression x) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArray[a](Printer printer, a[] items, FSharpFunc`2 print, FSharpFunc`2 printSeparator) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 135
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCommaSeparatedArray(Printer printer, Expression[] items) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCallExpression(Printer printer, Expression callee, Expression[] args, TypeAnnotation[] typeArguments, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1235
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer-PrintCommaSeparatedArray@229-10.Invoke(Printer p, Expression x) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArray[a](Printer printer, a[] items, FSharpFunc`2 print, FSharpFunc`2 printSeparator) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 135
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCommaSeparatedArray(Printer printer, Expression[] items) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCallExpression(Printer printer, Expression callee, Expression[] args, TypeAnnotation[] typeArguments, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1235
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintProductiveStatement(Printer printer, Statement s, FSharpOption`1 printSeparator) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 78
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer-PrintBlock@88.Invoke(Printer p, Statement s) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 88
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintBlock[a](Printer printer, a[] nodes, FSharpFunc`2 printNode, FSharpFunc`2 printSeparator, FSharpOption`1 skipNewLineAtEnd) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 61
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArrowFunctionExpression(Printer printer, Parameter[] parameters, BlockStatement body, FSharpOption`1 returnType, TypeParameter[] typeParameters, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1041
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer-PrintCommaSeparatedArray@229-10.Invoke(Printer p, Expression x) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintArray[a](Printer printer, a[] items, FSharpFunc`2 print, FSharpFunc`2 printSeparator) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 135
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCommaSeparatedArray(Printer printer, Expression[] items) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 229
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintCallExpression(Printer printer, Expression callee, Expression[] args, TypeAnnotation[] typeArguments, FSharpOption`1 loc) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1235
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintProductiveStatement(Printer printer, Statement s, FSharpOption`1 printSeparator) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 78
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer-PrintBlock@88.Invoke(Printer p, Statement s) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 88
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintBlock[a](Printer printer, a[] nodes, FSharpFunc`2 printNode, FSharpFunc`2 printSeparator, FSharpOption`1 skipNewLineAtEnd) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 61
   at Fable.Transforms.BabelPrinter.PrinterExtensions.Printer.PrintDeclaration(Printer printer, Declaration decl) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 664
   at Fable.Transforms.BabelPrinter.printDeclWithExtraLine@1558-1.Invoke(Printer printer, ModuleDeclaration decl) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1558
   at [email protected](ModuleDeclaration decl) in /Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/Fable.Transforms/BabelPrinter.fs:line 1585
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2) in /home/dev/Projects/fsharp/src/FSharp.Core/async.fs:line 510
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in /home/dev/Projects/fsharp/src/FSharp.Core/async.fs:line 112

Repro code

Add |> CmdLine.appendRaw "--sourceMaps" to src/Fable.Build/Quicktest/Core.fs and run ./build.sh quicktest javascript

Expected and actual results

Should compile

Related information

  • Fable version: 5.0.0-alpha.2
  • Operating system: OSX
@MangelMaxime
Copy link
Member Author

MangelMaxime commented Dec 17, 2024

It looks like the issue happens when a CE exist in the code:

let testCaseAsync f =
    async {
        do! f ()
    }

or

let testCaseAsync f =
    promise {
        do! f ()
    }

both fails

@MangelMaxime
Copy link
Member Author

Comparing the calls to AddSourceMapping

member _.AddSourceMapping(srcLine, srcCol, genLine, genCol, file, displayName) =

It seems like the problem is from do! which don't return its information now:

Fable 4.24.0

srcLine: 9
srcCol: 4
genLine: 4
genCol: 11
file: Some
  "/Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/quicktest/QuickTest.fs"
displayName: None
                    

srcLine: 9
srcCol: 4
genLine: 4
genCol: 11
file: Some
  "/Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/quicktest/QuickTest.fs"
displayName: Some "``builder@``"

srcLine: 10
srcCol: 12
genLine: 4
genCol: 33
file: Some
  "/Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/quicktest/QuickTest.fs"
displayName: None

Fable 5

srcLine: 9
srcCol: 4
genLine: 4
genCol: 11
file: Some
  "/Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/quicktest/QuickTest.fs"
displayName: None
                    

srcLine: 9
srcCol: 4
genLine: 4
genCol: 11
file: Some
  "/Users/mmangel/Workspaces/Github/fable-compiler/Fable/src/quicktest/QuickTest.fs"
displayName: Some "``builder@``"
                    

srcLine: 0
srcCol: 0
genLine: 4
genCol: 33
file: Some "unknown"
displayName: None

See the last paragraph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant