File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change 668668"""
669669Base. @constprop :aggressive function norm (itr, p:: Real = 2 )
670670 isempty (itr) && return float (norm (zero (eltype (itr))))
671+ v, s = iterate (itr)
672+ ! isnothing (s) && ! ismissing (v) && v == itr && throw (ArgumentError (
673+ " cannot evaluate norm recursively if the type of the initial element is identical to that of the container" ))
671674 if p == 2
672675 return norm2 (itr)
673676 elseif p == 1
Original file line number Diff line number Diff line change 571571 @test_broken ismissing (norm (x, 0 ))
572572end
573573
574+ @testset " avoid stackoverflow of norm on AbstractChar" begin
575+ @test_throws ArgumentError norm (' a' )
576+ @test_throws ArgumentError norm ([' a' , ' b' ])
577+ @test_throws ArgumentError norm (" s" )
578+ @test_throws ArgumentError norm ([" s" , " t" ])
579+ end
580+
574581@testset " peakflops" begin
575582 @test LinearAlgebra. peakflops (1024 , eltype= Float32, ntrials= 2 ) > 0
576583end
You can’t perform that action at this time.
0 commit comments