Skip to content

Commit 80fb6c8

Browse files
committed
Only refuse to define functions starting with a capital letter when they have no required arguments
1 parent 31a823e commit 80fb6c8

File tree

1 file changed

+3
-1
lines changed
  • app/server/ruby/lib/sonicpi/lang

1 file changed

+3
-1
lines changed

app/server/ruby/lib/sonicpi/lang/core.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2751,7 +2751,9 @@ def define(name, &block)
27512751
raise ArgumentError, "A function called #{name} is already part of Sonic Pi's core API. Please choose another name."
27522752
end
27532753

2754-
raise ArgumentError, "Function names can't start with a capital letter." if name.to_s =~ /^[A-Z]/
2754+
if block.arity == 0 && name.to_s =~ /^[A-Z]/
2755+
raise ArgumentError, "Functions with no required parameters can't start with a capital letter."
2756+
end
27552757

27562758
if already_defined
27572759
__info "Redefining fn #{name.inspect}"

0 commit comments

Comments
 (0)