ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:109995] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2
@ 2022-09-22  9:47 hsbt (Hiroshi SHIBATA)
  2022-09-27  3:49 ` [ruby-core:110099] " hsbt (Hiroshi SHIBATA)
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: hsbt (Hiroshi SHIBATA) @ 2022-09-22  9:47 UTC (permalink / raw)
  To: ruby-core

Issue #19016 has been reported by hsbt (Hiroshi SHIBATA).

----------------------------------------
Bug #19016: syntax_suggest is not working with Ruby 3.2.0-preview2
https://bugs.ruby-lang.org/issues/19016

* Author: hsbt (Hiroshi SHIBATA)
* Status: Assigned
* Priority: Normal
* Assignee: hsbt (Hiroshi SHIBATA)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
`syntax_suggest` is merged as default gems in Ruby 3.2.0-preview2. But it's not working yet.

```
$ cat bar.rb
def foo
  def bar
end

$ ruby -v bar.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
bar.rb:3: syntax error, unexpected end-of-input, expecting `end'
```

and gem version is also not working now.

```
$ cat foo.rb
require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "syntax_suggest"
end

require_relative "bar"
```

$ ruby -v foo.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
foo.rb:8:in `require_relative': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from foo.rb:8:in `<main>'
```

But Ruby 3.1 is works.

```
$ ruby -v foo.rb
ruby 3.1.3p51 (2022-09-10 revision 9581248c4a) [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
--> /path/to/bar.rb

Unmatched keyword, missing `end' ?

  1  def foo
❯ 2    def bar
  3  end

/Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from /Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require_relative'
        from foo.rb:8:in `<main>'
```



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:110099] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2
  2022-09-22  9:47 [ruby-core:109995] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2 hsbt (Hiroshi SHIBATA)
@ 2022-09-27  3:49 ` hsbt (Hiroshi SHIBATA)
  2022-09-27  6:47 ` [ruby-core:110100] " hsbt (Hiroshi SHIBATA)
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hsbt (Hiroshi SHIBATA) @ 2022-09-27  3:49 UTC (permalink / raw)
  To: ruby-core

Issue #19016 has been updated by hsbt (Hiroshi SHIBATA).


I investigated this.

https://github.com/ruby/syntax_suggest/blob/main/lib/syntax_suggest/api.rb#L67

```
    Timeout.timeout(timeout) do
      record_dir ||= ENV["DEBUG"] ? "tmp" : nil
      search = CodeSearch.new(source, record_dir: record_dir).call
    end
```

This block raises `#<ThreadError: can't alloc thread>` with Ruby 3.2.0-preview2 and master branch. When I commented-out this `Timeout.timeout`, syntax_suggest is working fine.

I bisected `timeout.rb`. After https://github.com/ruby/ruby/commit/89fbec224d8e1fa35e82bf2712c5a5fd3dc06b83 happens this `ThreadError` with syntax_suggest. I'm not sure why timeout.rb raises `ThreadError` when using syntax_suggest. 

----------------------------------------
Bug #19016: syntax_suggest is not working with Ruby 3.2.0-preview2
https://bugs.ruby-lang.org/issues/19016#change-99357

* Author: hsbt (Hiroshi SHIBATA)
* Status: Assigned
* Priority: Normal
* Assignee: hsbt (Hiroshi SHIBATA)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
`syntax_suggest` is merged as default gems in Ruby 3.2.0-preview2. But it's not working yet.

```
$ cat bar.rb
def foo
  def bar
end

$ ruby -v bar.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
bar.rb:3: syntax error, unexpected end-of-input, expecting `end'
```

and gem version is also not working now.

```
$ cat foo.rb
require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "syntax_suggest"
end

require_relative "bar"
```

```
$ ruby -v foo.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
foo.rb:8:in `require_relative': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from foo.rb:8:in `<main>'
```

But Ruby 3.1 is works.

```
$ ruby -v foo.rb
ruby 3.1.3p51 (2022-09-10 revision 9581248c4a) [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
--> /path/to/bar.rb

Unmatched keyword, missing `end' ?

  1  def foo
❯ 2    def bar
  3  end

/Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from /Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require_relative'
        from foo.rb:8:in `<main>'
```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:110100] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2
  2022-09-22  9:47 [ruby-core:109995] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2 hsbt (Hiroshi SHIBATA)
  2022-09-27  3:49 ` [ruby-core:110099] " hsbt (Hiroshi SHIBATA)
@ 2022-09-27  6:47 ` hsbt (Hiroshi SHIBATA)
  2022-09-27  8:10 ` [ruby-core:110103] " mame (Yusuke Endoh)
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hsbt (Hiroshi SHIBATA) @ 2022-09-27  6:47 UTC (permalink / raw)
  To: ruby-core

Issue #19016 has been updated by hsbt (Hiroshi SHIBATA).


@mame try to fix this `ThreadError` at https://github.com/ruby/ruby/pull/6452

----------------------------------------
Bug #19016: syntax_suggest is not working with Ruby 3.2.0-preview2
https://bugs.ruby-lang.org/issues/19016#change-99358

* Author: hsbt (Hiroshi SHIBATA)
* Status: Assigned
* Priority: Normal
* Assignee: hsbt (Hiroshi SHIBATA)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
`syntax_suggest` is merged as default gems in Ruby 3.2.0-preview2. But it's not working yet.

```
$ cat bar.rb
def foo
  def bar
end

$ ruby -v bar.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
bar.rb:3: syntax error, unexpected end-of-input, expecting `end'
```

and gem version is also not working now.

```
$ cat foo.rb
require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "syntax_suggest"
end

require_relative "bar"
```

```
$ ruby -v foo.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
foo.rb:8:in `require_relative': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from foo.rb:8:in `<main>'
```

But Ruby 3.1 is works.

```
$ ruby -v foo.rb
ruby 3.1.3p51 (2022-09-10 revision 9581248c4a) [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
--> /path/to/bar.rb

Unmatched keyword, missing `end' ?

  1  def foo
❯ 2    def bar
  3  end

/Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from /Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require_relative'
        from foo.rb:8:in `<main>'
```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:110103] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2
  2022-09-22  9:47 [ruby-core:109995] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2 hsbt (Hiroshi SHIBATA)
  2022-09-27  3:49 ` [ruby-core:110099] " hsbt (Hiroshi SHIBATA)
  2022-09-27  6:47 ` [ruby-core:110100] " hsbt (Hiroshi SHIBATA)
@ 2022-09-27  8:10 ` mame (Yusuke Endoh)
  2022-09-27 18:25 ` [ruby-core:110111] " Eregon (Benoit Daloze)
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mame (Yusuke Endoh) @ 2022-09-27  8:10 UTC (permalink / raw)
  To: ruby-core

Issue #19016 has been updated by mame (Yusuke Endoh).


There are two different sub-issues in this issue.

### 1. syntax_suggest does not work for `ruby foo.rb`.

This is because a SyntaxError exception is not thrown even if there is a syntax error in foo.rb of `ruby foo.rb`. Instead, the interpreter prints the syntax error directly. So `Exception#detailed_message` is not called, which means syntax_suggest cannot intercept the exception handling.

This could be fixed by throwing a SyntaxError exception even if there is a parse error in foo.rb, but I don't know how hard this fix will be implemented.

### 2. syntax_suggest does not work for `ruby -e 'load "foo.rb"'`.

In this case, a SyntaxError exception is thrown, so `Exception#detailed_message` of syntax_suggest is actually called.
However, `Exception#detailed_message` is called after the interpreter termination process has started.
It is prohibited to create a new thread in this state, but syntax_suggest uses Timeout.timeout, which tries to create a new thread.
This causes the failure `#<ThreadError: can't alloc thread>` which @hsbt mentioned.

[My PR](https://github.com/ruby/ruby/pull/6452) changes the order so that `Exception#detailed_message` is called *before* the interpreter termination process.
However, I am a little afraid that this change has unforeseen side effects because it will print an error message when other threads are still running.

@ko1 pointed that the following script prints `sub thread (RuntimeError)` and then `main thread (RuntimeError)` in Ruby 3.1, and that `main thread (RuntimeError)` and then `sub thread (RuntimeError)` with my PR applied.

```ruby
Thread.new { begin sleep; ensure; raise "sub thread"; end }
raise "main thread"
```

```
$ ruby -v tt.rb
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
#<Thread:0x00007ffff3f0b2e8 tt.rb:1 aborting> terminated with exception (report_on_exception is true):
tt.rb:1:in `ensure in block in <main>': sub thread (RuntimeError)
        from tt.rb:1:in `block in <main>'
tt.rb:2:in `<main>': main thread (RuntimeError)
```

```
$ ./miniruby -v tt.rb
ruby 3.2.0dev (2022-09-27T06:08:48Z error_print-before.. 4e8618306b) [x86_64-linux]
tt.rb:2:in `<main>': main thread (RuntimeError)
#<Thread:0x00007ffff7408fb8 tt.rb:1 aborting> terminated with exception (report_on_exception is true):
tt.rb:1:in `ensure in block in <main>': sub thread (RuntimeError)
        from tt.rb:1:in `block in <main>'
```

----------------------------------------
Bug #19016: syntax_suggest is not working with Ruby 3.2.0-preview2
https://bugs.ruby-lang.org/issues/19016#change-99361

* Author: hsbt (Hiroshi SHIBATA)
* Status: Assigned
* Priority: Normal
* Assignee: hsbt (Hiroshi SHIBATA)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
`syntax_suggest` is merged as default gems in Ruby 3.2.0-preview2. But it's not working yet.

```
$ cat bar.rb
def foo
  def bar
end

$ ruby -v bar.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
bar.rb:3: syntax error, unexpected end-of-input, expecting `end'
```

and gem version is also not working now.

```
$ cat foo.rb
require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "syntax_suggest"
end

require_relative "bar"
```

```
$ ruby -v foo.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
foo.rb:8:in `require_relative': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from foo.rb:8:in `<main>'
```

But Ruby 3.1 is works.

```
$ ruby -v foo.rb
ruby 3.1.3p51 (2022-09-10 revision 9581248c4a) [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
--> /path/to/bar.rb

Unmatched keyword, missing `end' ?

  1  def foo
❯ 2    def bar
  3  end

/Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from /Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require_relative'
        from foo.rb:8:in `<main>'
```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:110111] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2
  2022-09-22  9:47 [ruby-core:109995] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2 hsbt (Hiroshi SHIBATA)
                   ` (2 preceding siblings ...)
  2022-09-27  8:10 ` [ruby-core:110103] " mame (Yusuke Endoh)
@ 2022-09-27 18:25 ` Eregon (Benoit Daloze)
  2022-10-06 14:35 ` [ruby-core:110210] " mame (Yusuke Endoh)
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Eregon (Benoit Daloze) @ 2022-09-27 18:25 UTC (permalink / raw)
  To: ruby-core

Issue #19016 has been updated by Eregon (Benoit Daloze).


The current shutdown order in TruffleRuby is:
1. execute main script (and save exception if any)
2. run at_exit hooks
3. print main script's exception with `.full_message`
4. kill and wait all threads (which still runs some Ruby code in `ensure`)
5. internal cleanups which do not need to run Ruby code

Which seems already the order with your change.
I think we shouldn't run any Ruby code after "kill and wait all threads" (because the kill might have caused inconsistent state and triggered in the middle of an `ensure`, etc), so I think this change makes a lot of sense.

----------------------------------------
Bug #19016: syntax_suggest is not working with Ruby 3.2.0-preview2
https://bugs.ruby-lang.org/issues/19016#change-99369

* Author: hsbt (Hiroshi SHIBATA)
* Status: Assigned
* Priority: Normal
* Assignee: hsbt (Hiroshi SHIBATA)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
`syntax_suggest` is merged as default gems in Ruby 3.2.0-preview2. But it's not working yet.

```
$ cat bar.rb
def foo
  def bar
end

$ ruby -v bar.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
bar.rb:3: syntax error, unexpected end-of-input, expecting `end'
```

and gem version is also not working now.

```
$ cat foo.rb
require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "syntax_suggest"
end

require_relative "bar"
```

```
$ ruby -v foo.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
foo.rb:8:in `require_relative': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from foo.rb:8:in `<main>'
```

But Ruby 3.1 is works.

```
$ ruby -v foo.rb
ruby 3.1.3p51 (2022-09-10 revision 9581248c4a) [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
--> /path/to/bar.rb

Unmatched keyword, missing `end' ?

  1  def foo
❯ 2    def bar
  3  end

/Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from /Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require_relative'
        from foo.rb:8:in `<main>'
```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:110210] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2
  2022-09-22  9:47 [ruby-core:109995] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2 hsbt (Hiroshi SHIBATA)
                   ` (3 preceding siblings ...)
  2022-09-27 18:25 ` [ruby-core:110111] " Eregon (Benoit Daloze)
@ 2022-10-06 14:35 ` mame (Yusuke Endoh)
  2022-10-06 16:02 ` [ruby-core:110214] " Eregon (Benoit Daloze)
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mame (Yusuke Endoh) @ 2022-10-06 14:35 UTC (permalink / raw)
  To: ruby-core

Issue #19016 has been updated by mame (Yusuke Endoh).


At the dev meeting, @nobu proposed a slightly different order of termination process: (1) calls #detailed_message and keep the result string, (2) terminates all threads, and (3) prints the kept message.

@nobu Do you create a patch?

----------------------------------------
Bug #19016: syntax_suggest is not working with Ruby 3.2.0-preview2
https://bugs.ruby-lang.org/issues/19016#change-99493

* Author: hsbt (Hiroshi SHIBATA)
* Status: Assigned
* Priority: Normal
* Assignee: hsbt (Hiroshi SHIBATA)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
`syntax_suggest` is merged as default gems in Ruby 3.2.0-preview2. But it's not working yet.

```
$ cat bar.rb
def foo
  def bar
end

$ ruby -v bar.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
bar.rb:3: syntax error, unexpected end-of-input, expecting `end'
```

and gem version is also not working now.

```
$ cat foo.rb
require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "syntax_suggest"
end

require_relative "bar"
```

```
$ ruby -v foo.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
foo.rb:8:in `require_relative': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from foo.rb:8:in `<main>'
```

But Ruby 3.1 is works.

```
$ ruby -v foo.rb
ruby 3.1.3p51 (2022-09-10 revision 9581248c4a) [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
--> /path/to/bar.rb

Unmatched keyword, missing `end' ?

  1  def foo
❯ 2    def bar
  3  end

/Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from /Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require_relative'
        from foo.rb:8:in `<main>'
```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:110214] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2
  2022-09-22  9:47 [ruby-core:109995] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2 hsbt (Hiroshi SHIBATA)
                   ` (4 preceding siblings ...)
  2022-10-06 14:35 ` [ruby-core:110210] " mame (Yusuke Endoh)
@ 2022-10-06 16:02 ` Eregon (Benoit Daloze)
  2022-10-07 21:44 ` [ruby-core:110233] " schneems (Richard Schneeman)
  2022-11-14  2:32 ` [ruby-core:110738] " hsbt (Hiroshi SHIBATA)
  7 siblings, 0 replies; 9+ messages in thread
From: Eregon (Benoit Daloze) @ 2022-10-06 16:02 UTC (permalink / raw)
  To: ruby-core

Issue #19016 has been updated by Eregon (Benoit Daloze).


Sounds OK-ish except I think `full_message` should be called instead of `detailed_message`.
Also if terminating all threads takes a while it delays the printing significantly, that's not so nice.
The order I posted above seems much cleaner.

----------------------------------------
Bug #19016: syntax_suggest is not working with Ruby 3.2.0-preview2
https://bugs.ruby-lang.org/issues/19016#change-99499

* Author: hsbt (Hiroshi SHIBATA)
* Status: Assigned
* Priority: Normal
* Assignee: hsbt (Hiroshi SHIBATA)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
`syntax_suggest` is merged as default gems in Ruby 3.2.0-preview2. But it's not working yet.

```
$ cat bar.rb
def foo
  def bar
end

$ ruby -v bar.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
bar.rb:3: syntax error, unexpected end-of-input, expecting `end'
```

and gem version is also not working now.

```
$ cat foo.rb
require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "syntax_suggest"
end

require_relative "bar"
```

```
$ ruby -v foo.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
foo.rb:8:in `require_relative': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from foo.rb:8:in `<main>'
```

But Ruby 3.1 is works.

```
$ ruby -v foo.rb
ruby 3.1.3p51 (2022-09-10 revision 9581248c4a) [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
--> /path/to/bar.rb

Unmatched keyword, missing `end' ?

  1  def foo
❯ 2    def bar
  3  end

/Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from /Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require_relative'
        from foo.rb:8:in `<main>'
```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:110233] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2
  2022-09-22  9:47 [ruby-core:109995] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2 hsbt (Hiroshi SHIBATA)
                   ` (5 preceding siblings ...)
  2022-10-06 16:02 ` [ruby-core:110214] " Eregon (Benoit Daloze)
@ 2022-10-07 21:44 ` schneems (Richard Schneeman)
  2022-11-14  2:32 ` [ruby-core:110738] " hsbt (Hiroshi SHIBATA)
  7 siblings, 0 replies; 9+ messages in thread
From: schneems (Richard Schneeman) @ 2022-10-07 21:44 UTC (permalink / raw)
  To: ruby-core

Issue #19016 has been updated by schneems (Richard Schneeman).


Thank you all for looking at this issue. I have some more cycles now. I took a look at the explanation and the PR. I don't feel equipped to weigh in on the implementation. I understand the problem description and proposed solution(s). 

----------------------------------------
Bug #19016: syntax_suggest is not working with Ruby 3.2.0-preview2
https://bugs.ruby-lang.org/issues/19016#change-99517

* Author: hsbt (Hiroshi SHIBATA)
* Status: Assigned
* Priority: Normal
* Assignee: hsbt (Hiroshi SHIBATA)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
`syntax_suggest` is merged as default gems in Ruby 3.2.0-preview2. But it's not working yet.

```
$ cat bar.rb
def foo
  def bar
end

$ ruby -v bar.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
bar.rb:3: syntax error, unexpected end-of-input, expecting `end'
```

and gem version is also not working now.

```
$ cat foo.rb
require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "syntax_suggest"
end

require_relative "bar"
```

```
$ ruby -v foo.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
foo.rb:8:in `require_relative': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from foo.rb:8:in `<main>'
```

But Ruby 3.1 is works.

```
$ ruby -v foo.rb
ruby 3.1.3p51 (2022-09-10 revision 9581248c4a) [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
--> /path/to/bar.rb

Unmatched keyword, missing `end' ?

  1  def foo
❯ 2    def bar
  3  end

/Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from /Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require_relative'
        from foo.rb:8:in `<main>'
```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [ruby-core:110738] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2
  2022-09-22  9:47 [ruby-core:109995] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2 hsbt (Hiroshi SHIBATA)
                   ` (6 preceding siblings ...)
  2022-10-07 21:44 ` [ruby-core:110233] " schneems (Richard Schneeman)
@ 2022-11-14  2:32 ` hsbt (Hiroshi SHIBATA)
  7 siblings, 0 replies; 9+ messages in thread
From: hsbt (Hiroshi SHIBATA) @ 2022-11-14  2:32 UTC (permalink / raw)
  To: ruby-core

Issue #19016 has been updated by hsbt (Hiroshi SHIBATA).

Assignee changed from hsbt (Hiroshi SHIBATA) to nobu (Nobuyoshi Nakada)

`syntax_suggest` is not working 3.2.0-preview3 too. @nobu will resolve this until preview4.

----------------------------------------
Bug #19016: syntax_suggest is not working with Ruby 3.2.0-preview2
https://bugs.ruby-lang.org/issues/19016#change-100074

* Author: hsbt (Hiroshi SHIBATA)
* Status: Assigned
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN
----------------------------------------
`syntax_suggest` is merged as default gems in Ruby 3.2.0-preview2. But it's not working yet.

```
$ cat bar.rb
def foo
  def bar
end

$ ruby -v bar.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
bar.rb:3: syntax error, unexpected end-of-input, expecting `end'
```

and gem version is also not working now.

```
$ cat foo.rb
require "bundler/inline"

gemfile do
  source "https://rubygems.org"
  gem "syntax_suggest"
end

require_relative "bar"
```

```
$ ruby -v foo.rb
ruby 3.2.0dev (2022-09-22T05:37:56Z master f07e651a90) +YJIT [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
foo.rb:8:in `require_relative': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from foo.rb:8:in `<main>'
```

But Ruby 3.1 is works.

```
$ ruby -v foo.rb
ruby 3.1.3p51 (2022-09-10 revision 9581248c4a) [arm64-darwin22]
/path/to/bar.rb:3: warning: mismatched indentations at 'end' with 'def' at 2
--> /path/to/bar.rb

Unmatched keyword, missing `end' ?

  1  def foo
❯ 2    def bar
  3  end

/Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require': /path/to/bar.rb:3: syntax error, unexpected end-of-input, expecting `end' (SyntaxError)
        from /Users/hsbt/.local/share/gem/gems/syntax_suggest-0.0.1/lib/syntax_suggest/core_ext.rb:93:in `require_relative'
        from foo.rb:8:in `<main>'
```




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-11-14  2:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22  9:47 [ruby-core:109995] [Ruby master Bug#19016] syntax_suggest is not working with Ruby 3.2.0-preview2 hsbt (Hiroshi SHIBATA)
2022-09-27  3:49 ` [ruby-core:110099] " hsbt (Hiroshi SHIBATA)
2022-09-27  6:47 ` [ruby-core:110100] " hsbt (Hiroshi SHIBATA)
2022-09-27  8:10 ` [ruby-core:110103] " mame (Yusuke Endoh)
2022-09-27 18:25 ` [ruby-core:110111] " Eregon (Benoit Daloze)
2022-10-06 14:35 ` [ruby-core:110210] " mame (Yusuke Endoh)
2022-10-06 16:02 ` [ruby-core:110214] " Eregon (Benoit Daloze)
2022-10-07 21:44 ` [ruby-core:110233] " schneems (Richard Schneeman)
2022-11-14  2:32 ` [ruby-core:110738] " hsbt (Hiroshi SHIBATA)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).