Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: addccf23c464
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a90d9a8b3ccd
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Mar 1, 2015

  1. Produce a warning on private attribute accessors

    People seem to do that a lot after Sandi's book and not many of them
    realize it actually produces a warning in CRuby.
    
    Tried getting TestModule#test_attr out of the CRuby excluded failures,
    because it was the only existing test I saw hinting of the behaviour,
    however it also test that attribute names can't be a invalid
    identifiers, which seems to go fine in JRuby.
    gsamokovarov committed Mar 1, 2015
    Copy the full SHA
    9dd446f View commit details

Commits on Mar 3, 2015

  1. Merge pull request #2637 from gsamokovarov/private-attrs

    Produce a warning on private attribute accessors
    enebo committed Mar 3, 2015
    Copy the full SHA
    a90d9a8 View commit details
Showing with 4 additions and 2 deletions.
  1. +2 −2 core/src/main/java/org/jruby/RubyModule.java
  2. +2 −0 core/src/main/java/org/jruby/common/IRubyWarnings.java
4 changes: 2 additions & 2 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -1421,10 +1421,10 @@ private void addAccessor(ThreadContext context, String internedName, Visibility
final Ruby runtime = context.runtime;

if (visibility == PRIVATE) {
//FIXME warning
runtime.getWarnings().warn(ID.PRIVATE_ACCESSOR, "private attribute?");
} else if (visibility == MODULE_FUNCTION) {
runtime.getWarnings().warn(ID.ACCESSOR_MODULE_FUNCTION, "attribute accessor as module_function");
visibility = PRIVATE;
// FIXME warning
}

if (!(IdUtil.isLocal(internedName) || IdUtil.isConstant(internedName))) {
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/common/IRubyWarnings.java
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ public interface IRubyWarnings {
public enum ID {
AMBIGUOUS_ARGUMENT,
ACCESSOR_NOT_INITIALIZED,
ACCESSOR_MODULE_FUNCTION,
ARGUMENT_AS_PREFIX,
ARGUMENT_EXTRA_SPACE,
ASSIGNMENT_IN_CONDITIONAL,
@@ -72,6 +73,7 @@ public enum ID {
NOT_IMPLEMENTED,
OBSOLETE_ARGUMENT,
PARENTHISE_ARGUMENTS,
PRIVATE_ACCESSOR,
PROXY_EXTENDED_LATE,
STATEMENT_NOT_REACHED,
LITERAL_IN_CONDITIONAL_RANGE,