Skip to content
Browse files

Merge pull request #283 from dekellum/1-6-backport-6865

1.6 backport: JRUBY-6865
  • Loading branch information...
2 parents eec9bbe + 254d8e5 commit 102f85a39f10c1579a8f7507d310a2264bedc45a @headius headius committed
Showing with 10 additions and 1 deletion.
  1. +5 −0 src/org/jruby/RubyModule.java
  2. +5 −1 src/org/jruby/util/IdUtil.java
View
5 src/org/jruby/RubyModule.java
@@ -1307,6 +1307,11 @@ private void addAccessor(ThreadContext context, String internedName, Visibility
visibility = PRIVATE;
// FIXME warning
}
+
+ if (!(IdUtil.isLocal(internedName) || IdUtil.isConstant(internedName))) {
+ throw runtime.newNameError("invalid attribute name", internedName);
+ }
+
final String variableName = ("@" + internedName).intern();
if (readable) {
addMethod(internedName, new JavaMethodZero(this, visibility, CallConfiguration.FrameNoneScopeNone) {
View
6 src/org/jruby/util/IdUtil.java
@@ -57,12 +57,16 @@ public static boolean isInstanceVariable(String id) {
public static boolean isGlobal(String id) {
return id.length()>0 && id.charAt(0) == '$';
}
+
+ public static boolean isPredicate(String id) {
+ return id.endsWith("?");
+ }
/**
* rb_is_local_id and is_local_id
*/
public static boolean isLocal(String id) {
- return !isGlobal(id) && !isClassVariable(id) && !isInstanceVariable(id) && !isConstant(id);
+ return !isGlobal(id) && !isClassVariable(id) && !isInstanceVariable(id) && !isConstant(id) && !isPredicate(id);
}
public static boolean isAttrSet(String id) {

0 comments on commit 102f85a

Please sign in to comment.
Something went wrong with that request. Please try again.