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

Nested "select type" statements not parsed correctly #181

Open
PaulXiCao opened this issue Oct 25, 2020 · 2 comments
Open

Nested "select type" statements not parsed correctly #181

PaulXiCao opened this issue Oct 25, 2020 · 2 comments

Comments

@PaulXiCao
Copy link
Contributor

For nested "select type" statements the syntax highlighting in vscode seems off. The code after the first "end select" is not highlighted anymore until the 2nd "end select".

This is an example code

program main
  implicit none

  type parent
    integer :: i
  end type

  type, extends(parent) :: child
    real :: r
  end type

  class(parent), allocatable :: a, b

  allocate (parent :: a, b)

  select type (x => a)
    type is (parent)
      select type (y => b)
        class is (parent)
        type is (child)
        class default
      end select
    type is (child)     ! not highlighted
    class default       ! not highlighted
  end select            ! not highlighted
end program

This is the debug output of the language server

$ fortls --debug_parser --debug_filepath=main.f90

Testing parser
  File = "main.f90"
  Detected format: free

=========
Parser Output
=========

=== No PreProc ===

program main !!! PROGRAM statement(1)
implicit none !!! IMPLICIT statement(2)
type parent !!! TYPE statement(4)
integer :: i !!! VARIABLE statement(5)
end type !!! END "TYPE" scope(6)
type, extends(parent) :: child !!! TYPE statement(8)
real :: r !!! VARIABLE statement(9)
end type !!! END "TYPE" scope(10)
class(parent), allocatable :: a, b !!! VARIABLE statement(12)
select type (x => a) !!! SELECT statement(16)
type is (parent) !!! SELECT statement(17)
select type (y => b) !!! SELECT statement(18)
class is (parent) !!! SELECT statement(19)
type is (child) !!! SELECT statement(20)
class default !!! SELECT statement(21)
end select !!! END "SELECT" scope(22)
type is (child)     ! not highlighted !!! SELECT statement(23)
class default       ! not highlighted !!! SELECT statement(24)
end select            ! not highlighted !!! END "SELECT" scope(25)
end program !!! END "PROGRAM" scope(27)

=========
Object Tree
=========

1: main
  4: main::parent
    6: main::parent::i
  4: main::child
    6: main::child::r
  6: main::a
  6: main::b
  10: main::#select1
    10: main::#select1::#select2
      6: main::#select1::#select2::x
    10: main::#select1::#select2::#select3
      6: main::#select1::#select2::#select3::x
      10: main::#select1::#select2::#select3::#select4
        6: main::#select1::#select2::#select3::#select4::y
      10: main::#select1::#select2::#select3::#select4::#select5
        6: main::#select1::#select2::#select3::#select4::#select5::y
      10: main::#select1::#select2::#select3::#select4::#select5::#select6
        6: main::#select1::#select2::#select3::#select4::#select5::#select6::y
    10: main::#select1::#select7
      6: main::#select1::#select7::x
    10: main::#select1::#select7::#select8
      6: main::#select1::#select7::#select8::x
4: main::parent
  6: main::parent::i
4: main::child
  6: main::child::r
10: main::#select1
  10: main::#select1::#select2
    6: main::#select1::#select2::x
  10: main::#select1::#select2::#select3
    6: main::#select1::#select2::#select3::x
    10: main::#select1::#select2::#select3::#select4
      6: main::#select1::#select2::#select3::#select4::y
    10: main::#select1::#select2::#select3::#select4::#select5
      6: main::#select1::#select2::#select3::#select4::#select5::y
    10: main::#select1::#select2::#select3::#select4::#select5::#select6
      6: main::#select1::#select2::#select3::#select4::#select5::#select6::y
  10: main::#select1::#select7
    6: main::#select1::#select7::x
  10: main::#select1::#select7::#select8
    6: main::#select1::#select7::#select8::x
10: main::#select1::#select2
  6: main::#select1::#select2::x
10: main::#select1::#select2::#select3
  6: main::#select1::#select2::#select3::x
  10: main::#select1::#select2::#select3::#select4
    6: main::#select1::#select2::#select3::#select4::y
  10: main::#select1::#select2::#select3::#select4::#select5
    6: main::#select1::#select2::#select3::#select4::#select5::y
  10: main::#select1::#select2::#select3::#select4::#select5::#select6
    6: main::#select1::#select2::#select3::#select4::#select5::#select6::y
10: main::#select1::#select2::#select3::#select4
  6: main::#select1::#select2::#select3::#select4::y
10: main::#select1::#select2::#select3::#select4::#select5
  6: main::#select1::#select2::#select3::#select4::#select5::y
10: main::#select1::#select2::#select3::#select4::#select5::#select6
  6: main::#select1::#select2::#select3::#select4::#select5::#select6::y
10: main::#select1::#select7
  6: main::#select1::#select7::x
10: main::#select1::#select7::#select8
  6: main::#select1::#select7::#select8::x

=========
Exportable Objects
=========

1: main
@gnikit
Copy link

gnikit commented Dec 5, 2020

@PaulXiCao I think what you are experiencing is because the Modern Fortran package has a few bugs when it comes to syntax highlighting. There is a PR open and ready to merge addressing this issue, see fortran-lang/vscode-fortran-support#201

@gnikit
Copy link

gnikit commented Oct 5, 2021

I suspect that this is fixed now since it was a Modern Fortran bug

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

No branches or pull requests

2 participants