* [ruby-core:81528] [Ruby trunk Bug#13623] meta-programming, adding sub-module fails with syntax error
[not found] <redmine.issue-13623.20170602143700@ruby-lang.org>
@ 2017-06-02 14:37 ` adriaan1
2017-06-02 14:43 ` [ruby-core:81529] " adriaan1
` (5 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: adriaan1 @ 2017-06-02 14:37 UTC (permalink / raw)
To: ruby-core
Issue #13623 has been reported by caschip (Aad Schippers).
----------------------------------------
Bug #13623: meta-programming, adding sub-module fails with syntax error
https://bugs.ruby-lang.org/issues/13623
* Author: caschip (Aad Schippers)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
The goal is to add a sub-module to a higher level module. The higher level module is derived from its name in a string. This works in one case and gives an unexpected syntax error in another case.
failing_meta:4: syntax error, unexpected '\n', expecting &. or :: or '[' or '.'
failing_meta:8: syntax error, unexpected keyword_end, expecting end-of-input
---Files--------------------------------
no_meta (72 Bytes)
working_meta (82 Bytes)
failing_meta (95 Bytes)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:81529] [Ruby trunk Bug#13623] meta-programming, adding sub-module fails with syntax error
[not found] <redmine.issue-13623.20170602143700@ruby-lang.org>
2017-06-02 14:37 ` [ruby-core:81528] [Ruby trunk Bug#13623] meta-programming, adding sub-module fails with syntax error adriaan1
@ 2017-06-02 14:43 ` adriaan1
2017-06-02 15:25 ` [ruby-core:81532] " shyouhei
` (4 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: adriaan1 @ 2017-06-02 14:43 UTC (permalink / raw)
To: ruby-core
Issue #13623 has been updated by caschip (Aad Schippers).
module Foo
end
# Failing with syntax error is the code below
module Object::const_get( 'Foo' )
module Bar
end
end
----------------------------------------
Bug #13623: meta-programming, adding sub-module fails with syntax error
https://bugs.ruby-lang.org/issues/13623#change-65234
* Author: caschip (Aad Schippers)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
The goal is to add a sub-module to a higher level module. The higher level module is derived from its name in a string. This works in one case and gives an unexpected syntax error in another case.
failing_meta:4: syntax error, unexpected '\n', expecting &. or :: or '[' or '.'
failing_meta:8: syntax error, unexpected keyword_end, expecting end-of-input
---Files--------------------------------
no_meta (72 Bytes)
working_meta (82 Bytes)
failing_meta (95 Bytes)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:81532] [Ruby trunk Bug#13623] meta-programming, adding sub-module fails with syntax error
[not found] <redmine.issue-13623.20170602143700@ruby-lang.org>
2017-06-02 14:37 ` [ruby-core:81528] [Ruby trunk Bug#13623] meta-programming, adding sub-module fails with syntax error adriaan1
2017-06-02 14:43 ` [ruby-core:81529] " adriaan1
@ 2017-06-02 15:25 ` shyouhei
2017-06-03 6:43 ` [ruby-core:81554] " adriaan1
` (3 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: shyouhei @ 2017-06-02 15:25 UTC (permalink / raw)
To: ruby-core
Issue #13623 has been updated by shyouhei (Shyouhei Urabe).
Well const_get('Foo') is syntactically a non-constant while const_get('Foo')::Bar is. This is the ultimate reason why working_meta works but failing_meta fails. If you want to meta-program you have to be explicit like const_get('Foo').module_eval { ... }.
----------------------------------------
Bug #13623: meta-programming, adding sub-module fails with syntax error
https://bugs.ruby-lang.org/issues/13623#change-65237
* Author: caschip (Aad Schippers)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
The goal is to add a sub-module to a higher level module. The higher level module is derived from its name in a string. This works in one case and gives an unexpected syntax error in another case.
failing_meta:4: syntax error, unexpected '\n', expecting &. or :: or '[' or '.'
failing_meta:8: syntax error, unexpected keyword_end, expecting end-of-input
---Files--------------------------------
no_meta (72 Bytes)
working_meta (82 Bytes)
failing_meta (95 Bytes)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:81554] [Ruby trunk Bug#13623] meta-programming, adding sub-module fails with syntax error
[not found] <redmine.issue-13623.20170602143700@ruby-lang.org>
` (2 preceding siblings ...)
2017-06-02 15:25 ` [ruby-core:81532] " shyouhei
@ 2017-06-03 6:43 ` adriaan1
2017-06-03 7:25 ` [ruby-core:81555] [Ruby trunk Bug#13623][Rejected] " nobu
` (2 subsequent siblings)
6 siblings, 0 replies; 7+ messages in thread
From: adriaan1 @ 2017-06-03 6:43 UTC (permalink / raw)
To: ruby-core
Issue #13623 has been updated by caschip (Aad Schippers).
So you are saying this is how it should work and not a bug? If that is true, I should close this. What do you mean when you say that Object::const_get('Foo')::Bar is syntactically a constant. Its contains characters that are not appropriate in constant names, like brackets and single quotes, and a method is called, const_get, to evaluate it. To me it is an expression a::b::c with two scope operators, two constants (Object and Bar) and one method call that returns a constant const_get('Foo') => Foo.
----------------------------------------
Bug #13623: meta-programming, adding sub-module fails with syntax error
https://bugs.ruby-lang.org/issues/13623#change-65257
* Author: caschip (Aad Schippers)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
The goal is to add a sub-module to a higher level module. The higher level module is derived from its name in a string. This works in one case and gives an unexpected syntax error in another case.
failing_meta:4: syntax error, unexpected '\n', expecting &. or :: or '[' or '.'
failing_meta:8: syntax error, unexpected keyword_end, expecting end-of-input
---Files--------------------------------
no_meta (72 Bytes)
working_meta (82 Bytes)
failing_meta (95 Bytes)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:81555] [Ruby trunk Bug#13623][Rejected] meta-programming, adding sub-module fails with syntax error
[not found] <redmine.issue-13623.20170602143700@ruby-lang.org>
` (3 preceding siblings ...)
2017-06-03 6:43 ` [ruby-core:81554] " adriaan1
@ 2017-06-03 7:25 ` nobu
2017-06-05 10:02 ` [ruby-core:81579] [Ruby trunk Bug#13623] " adriaan1
2017-06-05 10:24 ` [ruby-core:81580] " nobu
6 siblings, 0 replies; 7+ messages in thread
From: nobu @ 2017-06-03 7:25 UTC (permalink / raw)
To: ruby-core
Issue #13623 has been updated by nobu (Nobuyoshi Nakada).
Description updated
Status changed from Open to Rejected
`module` statement requires a **name**, not a constant object.
----------------------------------------
Bug #13623: meta-programming, adding sub-module fails with syntax error
https://bugs.ruby-lang.org/issues/13623#change-65258
* Author: caschip (Aad Schippers)
* Status: Rejected
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
The goal is to add a sub-module to a higher level module. The higher level module is derived from its name in a string. This works in one case and gives an unexpected syntax error in another case.
```
failing_meta:4: syntax error, unexpected '\n', expecting &. or :: or '[' or '.'
failing_meta:8: syntax error, unexpected keyword_end, expecting end-of-input
```
---Files--------------------------------
no_meta (72 Bytes)
working_meta (82 Bytes)
failing_meta (95 Bytes)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:81579] [Ruby trunk Bug#13623] meta-programming, adding sub-module fails with syntax error
[not found] <redmine.issue-13623.20170602143700@ruby-lang.org>
` (4 preceding siblings ...)
2017-06-03 7:25 ` [ruby-core:81555] [Ruby trunk Bug#13623][Rejected] " nobu
@ 2017-06-05 10:02 ` adriaan1
2017-06-05 10:24 ` [ruby-core:81580] " nobu
6 siblings, 0 replies; 7+ messages in thread
From: adriaan1 @ 2017-06-05 10:02 UTC (permalink / raw)
To: ruby-core
Issue #13623 has been updated by caschip (Aad Schippers).
Ok, you make it very clear. Indeed, in working_meta 'Bar' is not a constant but a name when statement 'module' is evaluated. Statement 'module' requires a name that does not exist in the scope yet. That name can be preceded by an expression that results in a scope. Default is the current scope. Name and scope expression are separated by double colon.
----------------------------------------
Bug #13623: meta-programming, adding sub-module fails with syntax error
https://bugs.ruby-lang.org/issues/13623#change-65282
* Author: caschip (Aad Schippers)
* Status: Rejected
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
The goal is to add a sub-module to a higher level module. The higher level module is derived from its name in a string. This works in one case and gives an unexpected syntax error in another case.
```
failing_meta:4: syntax error, unexpected '\n', expecting &. or :: or '[' or '.'
failing_meta:8: syntax error, unexpected keyword_end, expecting end-of-input
```
---Files--------------------------------
no_meta (72 Bytes)
working_meta (82 Bytes)
failing_meta (95 Bytes)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* [ruby-core:81580] [Ruby trunk Bug#13623] meta-programming, adding sub-module fails with syntax error
[not found] <redmine.issue-13623.20170602143700@ruby-lang.org>
` (5 preceding siblings ...)
2017-06-05 10:02 ` [ruby-core:81579] [Ruby trunk Bug#13623] " adriaan1
@ 2017-06-05 10:24 ` nobu
6 siblings, 0 replies; 7+ messages in thread
From: nobu @ 2017-06-05 10:24 UTC (permalink / raw)
To: ruby-core
Issue #13623 has been updated by nobu (Nobuyoshi Nakada).
caschip (Aad Schippers) wrote:
> Statement 'module' requires a name that does not exist in the scope yet.
A (small) correction: it may exist syntactically,
```
$ ruby -c -e 'X=1; module X; end'
Syntax OK
```
but a `TypeError` will be raised at runtime if it is not a `Module`.
```
$ ruby -e 'X=1; module X; end'
Traceback (most recent call last):
-e:1:in `<main>': X is not a module (TypeError)
```
----------------------------------------
Bug #13623: meta-programming, adding sub-module fails with syntax error
https://bugs.ruby-lang.org/issues/13623#change-65283
* Author: caschip (Aad Schippers)
* Status: Rejected
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
The goal is to add a sub-module to a higher level module. The higher level module is derived from its name in a string. This works in one case and gives an unexpected syntax error in another case.
```
failing_meta:4: syntax error, unexpected '\n', expecting &. or :: or '[' or '.'
failing_meta:8: syntax error, unexpected keyword_end, expecting end-of-input
```
---Files--------------------------------
no_meta (72 Bytes)
working_meta (82 Bytes)
failing_meta (95 Bytes)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-06-05 10:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-13623.20170602143700@ruby-lang.org>
2017-06-02 14:37 ` [ruby-core:81528] [Ruby trunk Bug#13623] meta-programming, adding sub-module fails with syntax error adriaan1
2017-06-02 14:43 ` [ruby-core:81529] " adriaan1
2017-06-02 15:25 ` [ruby-core:81532] " shyouhei
2017-06-03 6:43 ` [ruby-core:81554] " adriaan1
2017-06-03 7:25 ` [ruby-core:81555] [Ruby trunk Bug#13623][Rejected] " nobu
2017-06-05 10:02 ` [ruby-core:81579] [Ruby trunk Bug#13623] " adriaan1
2017-06-05 10:24 ` [ruby-core:81580] " nobu
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).