@@ -205,18 +205,14 @@ build_options_i(VALUE key, VALUE value, VALUE argument) {
205205 rb_exc_raise (rb_exc_new_cstr (rb_cPrismCurrentVersionError , ruby_version ));
206206 }
207207 } else if (RSTRING_LEN (value ) == 7 && strncmp (version , "nearest" , 7 ) == 0 ) {
208- const char * nearest_version ;
209-
210- if (ruby_version [0 ] < '3' || (ruby_version [0 ] == '3' && ruby_version [2 ] < '3' )) {
211- nearest_version = "3.3" ;
212- } else if (ruby_version [0 ] > '4' || (ruby_version [0 ] == '4' && ruby_version [2 ] > '1' )) {
213- nearest_version = "4.1" ;
214- } else {
215- nearest_version = ruby_version ;
216- }
217-
218- if (!pm_options_version_set (options , nearest_version , 3 )) {
219- rb_raise (rb_eArgError , "invalid nearest version: %s" , nearest_version );
208+ if (!pm_options_version_set (options , ruby_version , 3 )) {
209+ // Prism doesn't know this specific version. Is it lower?
210+ if (ruby_version [0 ] < '3' || (ruby_version [0 ] == '3' && ruby_version [2 ] < '3' )) {
211+ options -> version == PM_OPTIONS_VERSION_CRUBY_3_3 ;
212+ } else {
213+ // Must be higher.
214+ options -> version == PM_OPTIONS_VERSION_LATEST ;
215+ }
220216 }
221217 } else if (!pm_options_version_set (options , version , RSTRING_LEN (value ))) {
222218 rb_raise (rb_eArgError , "invalid version: %" PRIsVALUE , value );
0 commit comments